I thought I was getting the hang of all these wpf controls until I tried to put a checkbox and text in the XamComboEditor. The combobox is for a chat application, the selected item is the channel to send out on, the checkboxes are the channels to receive information from. I can get the combination to work but I have two problems. The first is the ComboBoxDataItem has a white border around it that I can't change to black. The second item is when I click on the text it doesn't select the item (this is great for the checkbox, bad for the name). I have to click to the right of the name to select it. My questions are 1) How do I turn the ComboBoxDataItem border to black, and 2) how do I get the click on the text to execute select item in the XamComboEditor. Below is my xaml and the C# code to fill the <Editors:XamComboEditor Grid.Column="3" Grid.Row="1" SelectedItemChanged="ChannelBoxOnSelectedItemChanged" CheckBox.Checked="ChannelBoxOnChecked" Background="Black" Foreground="White" Name="ChannelBox" IsAlwaysInEditMode="True" HorizontalContentAlignment="Stretch" HorizontalAlignment="Stretch"><Editors:XamComboEditor.Resources> <DataTemplate DataType="{x:Type Editors:ComboBoxDataItem}"> <StackPanel Orientation="Horizontal" Background="Black"> <CheckBox IsChecked="{Binding Path=Value.IsChecked}" VerticalAlignment="Center"> </CheckBox> <TextBox Text="{Binding Path=Value.Name}" VerticalAlignment="Center" Margin="3,0,0,0" Foreground="White" Background="Black"> </TextBox> </StackPanel> </DataTemplate></Editors:XamComboEditor.Resources></Editors:XamComboEditor>(ChannelList has an object with two properties, Name and IsChecked)var itemsProvider = new ComboBoxItemsProvider();for (int i = 0; i < ChannelList.Length - 1; i++){ var cb = new ComboBoxDataItem { Value = ChannelList[i] }; itemsProvider.Items.Add(cb);} ChannelBox.ItemsProvider = itemsProvider;
Hello,
You have to use a TextBlock instead of a TextBox, because the TextBox will get the focus and will enter edit mode. If you want to be able to modify the text, as you can do with the TextBox and get this running correctly, you can use a XamTextEditor.
Regarding the border, it was coming from the TextBox as well.
Doh. No wonder I couldn't figure it out! Brain saw textblock, hands saw textbox. Thanks for providing a second set of eyes.