Hey Ali, Please follow these steps. I check this on my side and it works..
1) Add
Childern
as one more property in
SubscriberGroupModel
class. It means -
List<Subscribergroupmodel> childern;
public List<Subscribergroupmodel> Childern
{
get { return childern; }
set
{
childern = value;
NotifyPropertyChanged("Childern");
}
}
2)After that change the Loaded method - (Window_Loaded)
private void Window_Loaded(object sender, RoutedEventArgs e)
{
List<Subscribergroupmodel> list = SubscriberGroupDB.GetCustomSubscriberGroup();
SubscriberGroupModel sgmobj = new SubscriberGroupModel();
sgmobj.Childern = list;
List<Subscribergroupmodel> obj = new List<Subscribergroupmodel>();
obj.Add(sgmobj);
MainComboBox.ItemsSource = obj;
}
3) And Lastly change in your XAML -
<ComboBox x:Name="MainComboBox" TextBoxBase.TextChanged="MainComboBox_TextChanged">
<ComboBox.ItemTemplate>
<DataTemplate>
<TreeView BorderBrush="Transparent" BorderThickness="0" ItemsSource="{Binding Childern}">
<TreeView.ItemTemplate>
<HierarchicalDataTemplate >
<CheckBox Content="{Binding Name}" Height="25" Width="80" />
</HierarchicalDataTemplate>
</TreeView.ItemTemplate>
</TreeView>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
I hope this will solve your problem...