I looked around, found something, and now I'm stuck in a drop-down list with two columns displayed in a drop-down list. I have xaml themes available, and the combobox "Style" is defined and works well, as expected, so the part is fine.
Now I have a combo box that should display two values, and think of it as a state reduction and state name for the drop-down list coming from the DataTable.DefaultView binding source for the items.
If i have
<my:cboStates TextSearch.TextPath="StateAbbrev"> <ComboBox.ItemTemplate> <DataTemplate> <StackPanel Orientation="Horizontal" TextSearch.Text="{Binding Path=StateAbbrev}"> <TextBlock Text="{Binding Path=StateAbbrev}"/> <TextBlock Text="{Binding Path=FullStateName}" Margin="10 0"/> </StackPanel> </DataTemplate> </ComboBox.ItemTemplate> </my:cboStates>
it works. Now, how / where am I stuck ... Now I want the same functionality to say 5 different forms and all, to display the same content, and if ever change (not this, but for other multi-column combobox) I I don’t want it to be directly in the form of a XAML file.
I was hoping to put themes in the dictionary resource file and just keep reusing this “style” over and over again. Has the meaning. However, when I do this, and bind to the data table, the only results I get when I try to do as a style is a drop-down menu showing the values
System.Data.DataRowView System.Data.DataRowView System.Data.DataRowView System.Data.DataRowView
instead of the actual 2 columns. Here's what I have in the dictionary of the words "topic."
<DataTemplate x:Key="myStateComboTemplate" > <StackPanel Orientation="Horizontal" > <TextBlock Text="{Binding Path=StateAbbrev}"/> <TextBlock Text="{Binding Path=FullStateName}"/> </StackPanel> </DataTemplate> <Style x:Key="StyleMyStatesCombobox" TargetType="{x:Type ComboBox}" BasedOn="{StaticResource MyOtherWorkingComboBoxStyle}" > <Setter Property="TextSearch.TextPath" Value="{Binding Path=StateAbbrev}" /> <Setter Property="ItemTemplate" Value="{StaticResource myStateComboTemplate}" /> </Style>
So, if I have TWO instances, my class “cboStates” created on the form set one to the explicit style specified by the first, and SECOND based on the “Style” setting, the second failed, only showing duplicate System.Data. DataRowView, not the actual contents of the data.
What am I missing.
So, to clarify what I'm looking for ... States ... ex data p>
AL Alabama AK Alaska AZ Arizona AR Arkansas CA California CO Colorado CT Connecticut DE Delaware
I want the combo box to display the abbreviated AL, AK, AZ, etc. And a narrower combo box. It will also be "SelectedValue" upon return.
The actual drop-down menu will contain the data listed above showing BOTH abbreviation AND a long description of the status.
Example of the desired character
