Hi,
How I can add dynamically treeview into the combobox in wpf.. thakx..
Hi,
How I can add dynamically treeview into the combobox in wpf.. thakx..
you can do it with click event handler as given
<TreeView Tag="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ComboBox}}" MouseClick="treeview_MouseClick" ItemsSource="{Binding Children}" x:Name="Tree">
with Click event you can get the ComboBox
private void treeview_MouseClick(object sender, RoutedEventArgs e)
{
try
{
TreeView treeview = sender as TreeView;
if(treeview == null)
return;
var combobox = treeview .Tag as ComboBox;
combobox .SelectedItem = treeview .SelectedItem;
}
catch (Exception e)
{
}
}