Forum Discussion
googleid_114358
12 years agoContributor
Hi Tanya.
Indeed we are using Data Binding. Let me explain a bit more how we proceed.
I attached 3 screenshots :
I also joined some source code. The XAML used to defined the treeview behaviour :
<TreeView Name="_treeView">
<TreeView.ItemTemplate>
<HierarchicalDataTemplate ItemsSource="{Binding Subordinates}">
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Path=Name}" />
<TextBlock Text="{Binding Path=Age}" />
</StackPanel>
</HierarchicalDataTemplate>
</TreeView.ItemTemplate>
</TreeView>
The C# class which contains data :
public MainWindow()
{
InitializeComponent();
var bob = new Person { Name = "Bob", Age = 34 };
var sally = new Person { Name = "Sally", Age = 28 };
_treeView.Items.Add(bob);
_treeView.Items.Add(sally);
sally.Subordinates.Add(new Person { Name = "Joe", Age = 15 });
}
public class Person
{
public Person()
{
Subordinates = new List<Person>();
}
public string Name { get; set; }
public int Age { get; set; }
public List<Person> Subordinates { get; private set; }
}
We are ready to any kind of change in order to make the ClickItem method work properly.
Regards,
Guillaume.
Indeed we are using Data Binding. Let me explain a bit more how we proceed.
I attached 3 screenshots :
01_GUI_TreeView - A GUI of an application using the DataBinding mechanism.
02_GUI_TestComplete - An OnScreen Action recorded in a keyword.
03_ObjectBrowser_TestComplete - The WPFObject (System.Windows.Controls.TreeView) as seen by TestComplete 8 or 9.
I also joined some source code. The XAML used to defined the treeview behaviour :
<TreeView Name="_treeView">
<TreeView.ItemTemplate>
<HierarchicalDataTemplate ItemsSource="{Binding Subordinates}">
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Path=Name}" />
<TextBlock Text="{Binding Path=Age}" />
</StackPanel>
</HierarchicalDataTemplate>
</TreeView.ItemTemplate>
</TreeView>
The C# class which contains data :
public MainWindow()
{
InitializeComponent();
var bob = new Person { Name = "Bob", Age = 34 };
var sally = new Person { Name = "Sally", Age = 28 };
_treeView.Items.Add(bob);
_treeView.Items.Add(sally);
sally.Subordinates.Add(new Person { Name = "Joe", Age = 15 });
}
public class Person
{
public Person()
{
Subordinates = new List<Person>();
}
public string Name { get; set; }
public int Age { get; set; }
public List<Person> Subordinates { get; private set; }
}
We are ready to any kind of change in order to make the ClickItem method work properly.
Regards,
Guillaume.
Related Content
- 3 years ago
- 7 years ago
Recent Discussions
- 2 days ago
- 2 days ago
- 5 days ago