My GroupStyle Header never appears in the combobox....
The Grouping is working fine....It's sole a binding issue but am not able to figure out.
<DataTemplate>
<Border Background="Red">
<TextBlock Text="{Binding Path=value}" />
</Border>
</DataTemplate>
</ComboBox.ItemTemplate>
<ComboBox.GroupStyle>
<GroupStyle>
<GroupStyle.HeaderTemplate>
<DataTemplate>
<StackPanel>
<TextBlock FontSize="12" FontWeight="Bold" Foreground="DarkGray">
<Button Content="{Binding Path=Location}"/>
<TextBlock Text="{Binding Path=Location}" />
<Button>bbbb</Button>
</TextBlock>
<ItemsPresenter/>
</StackPanel>
</DataTemplate>
</GroupStyle.HeaderTemplate>
</GroupStyle>
</ComboBox.GroupStyle>
</ComboBox>
/// /// Interaction logic for Window1.xaml /// public class store { public string Location { get; set; } public string value { get; set; } }
public partial class Window1 : Window
{
public Window1()
{
InitializeComponent();
ObservableCollection<store> myData = new ObservableCollection<store>();
store a = new store();
a.Location = "Group1";
a.value = "Item 1 ";
myData.Add(a);
store ab = new store();
ab.Location = "Bombay";
ab.value = "Item 2";
myData.Add(ab);
store ac = new store();
ac.Location = "Group2";
ac.value = "Item 11 ";
myData.Add(ac);
ICollectionView view = CollectionViewSource.GetDefaultView(myData);
view.GroupDescriptions.Add(new PropertyGroupDescription("Location"));
DataContext = myData;
}
}