I want to add button in combobox, which contains ItemTemplate. First, that I tried was this:
<ComboBox Name="oilWells_comboBox"
Style="{StaticResource MMComboBox}"
MaxWidth="100"
ItemsSource="{Binding DataContext.OilWellCollection, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=local:MainWindow}}"
Margin="0">
<ComboBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
<CheckBox IsChecked="{Binding Path=IsDisplay}" Checked="FilterDataGrid" Unchecked="FilterDataGrid">
<CheckBox.Content>
<TextBlock MinWidth="100" Text="{Binding Path=Name}" HorizontalAlignment="Center" TextWrapping="Wrap" TextTrimming="CharacterEllipsis"/>
</CheckBox.Content>
</CheckBox>
</StackPanel>
</DataTemplate>
</ComboBox.ItemTemplate>
<Button Content="Clear" Height="20" HorizontalAlignment="Stretch"></Button>
</ComboBox>
But I've got an exception, which said what i cant add items to control, which has ItemTemplate. The second one was this:
<ComboBox Name="oilWells_comboBox"
Style="{StaticResource MMComboBox}"
MaxWidth="100"
ItemsSource="{Binding DataContext.OilWellCollection, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=local:MainWindow}}"
Margin="0">
<ComboBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
<CheckBox IsChecked="{Binding Path=IsDisplay}" Checked="FilterDataGrid" Unchecked="FilterDataGrid">
<CheckBox.Content>
<TextBlock MinWidth="100" Text="{Binding Path=Name}" HorizontalAlignment="Center" TextWrapping="Wrap" TextTrimming="CharacterEllipsis"/>
<Button Content="Clear" Height="20" HorizontalAlignment="Stretch"></Button>
</CheckBox.Content>
</CheckBox>
</StackPanel>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
But in this case button adds after each checkbox. Have you any ideas, how to do this only once? Thanks you in advance)