1

I have this kind of object in code:

ArtOfTest.WebAii.Controls.Xaml.Wpf.ListBox

Items of it are in ItemTemplate. I have collection of it:

var listBoxItems = repairComapanyHintsList.Find.AllByType<ListBoxItem>();

and I want to get control from that DataTemplate. How can I do it? That solution doesn't work for DataTemplate (for other situations it's ok):

var textBlock = listBoxItem.Find.ByName("Name");

How can I get it? I tried this solution too, but that controls (from ArtOfTest) doesn't DependencyObject: How can I find WPF controls by name or type?

I want to select one element depend of that TextBox text value.

Community
  • 1
  • 1
darson1991
  • 406
  • 6
  • 18

1 Answers1

0

I solved it, but it is not very good solution. It works for me and maybe it will help somebody.

I do it like that:

var listBoxItem = repairCompanyList.Find.AllByType<ListBoxItem>().FirstOrDefault(r => r.Text == "Name");
Assert.IsNotNull(listBoxItem, "Lack of expected list box item");
listBoxItem.User.Click();

I checked

darson1991
  • 406
  • 6
  • 18