I Bind a ComboBox to an Entity.
I want the Combobox to display on each Item multiple values of different format (Integer, String and DateTime values), like this:
Item#1) 100 - Description - 01/01/2013
Item#2) 101 - Description - 01/01/2013
But the ComboBox only displays the SQL char (C# string) values, the others are empty:
Item#1) - Description -
Item#2) - Description -
I have to use a Converter, am I on the wrong path, or there is a simpler solution?
In XAML
<UserControl.Resources>
<CollectionViewSource x:Key="tSCHEDEViewSource" d:DesignSource="{d:DesignInstance my:TSCHEDE, CreateList=True}" />
<DataTemplate x:Key="SchedaTemplate">
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Path=KSCHEDA}" Width="60"></TextBlock>
<TextBlock Text="{Binding Path=DArticolo}" Width="200"></TextBlock>
<TextBlock Text=" - " Width="40"></TextBlock>
<TextBlock Text="{Binding Path=DStorico}" Width="150"></TextBlock>
</StackPanel>
</DataTemplate>
</UserControl.Resources>
<ComboBox ItemTemplate="{StaticResource SchedaTemplate}" Grid.Column="1" Grid.Row="1" Height="23" HorizontalAlignment="Left" ItemsSource="{Binding}" Margin="23,129,0,0" Name="tSCHEDEComboBox1" SelectedValuePath="KScheda" VerticalAlignment="Top" Width="393">
<ComboBox.ItemsPanel>
<ItemsPanelTemplate>
<VirtualizingStackPanel />
</ItemsPanelTemplate>
</ComboBox.ItemsPanel>
</ComboBox>
The .edmx Model
<EntityType Name="TSCHEDE">
<Key>
<PropertyRef Name="KSCHEDA" />
</Key>
<Property Name="KSCHEDA" Type="int" Nullable="false" />
<Property Name="KLINEA" Type="int" Nullable="false" />
<Property Name="DSCHEDA" Type="char" MaxLength="30" />
<Property Name="DSTORICO" Type="datetime" />
<Property Name="FINSMAN" Type="char" MaxLength="1" />
<Property Name="DNOTE" Type="char" MaxLength="255" />
<Property Name="FCANC" Type="char" MaxLength="1" />
<Property Name="DArticolo" Type="char" MaxLength="60" />
<Property Name="FFIGLIA" Type="char" MaxLength="1" />
</EntityType>
I think that you have problem with case sensitive. When you binding you must exactly rewrite name of the variable.
Try this:
In
SelectedValuePathyou also have wrong variable, change it toSelectedValuePath="KSCHEDA".