Dear All,
I am having a blank combobox when doing this,
'Code to fill Hospital Combobox (cmbHospital)
Private Sub FillHospital()
Dim objDBRelated As New DBRelated
cmbHospital.DataContext = objDBRelated.GetHospital() 'Retrun EntityCollection
AddHandler cmbHospital.SelectionChanged, AddressOf
cmbHospital_OnSelectionChanged
End Sub
I am calling this function on MyBase.Loaded
'Hospital Combobox XAMAL
'XAML
<ComboBox Grid.Column="1" Grid.Row="0" VerticalAlignment="Bottom"
Margin="10,0,10,0" Name="cmbHospital"
IsSynchronizedWithCurrentItem="True" ItemsSource="{Binding}"
ItemTemplate="{StaticResource HospitalListTemplate}"
/>
'HospitalListTemplate is defined as
<DataTemplate x:Key="HospitalListTemplate">
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Path=strDisplayAs}" Margin="0,0,2,0"
VerticalAlignment="Center"/>
<TextBlock VerticalAlignment="Center">
<Bold><Label Content="{Binding Path=intNoOfBeds}" /></Bold>
</TextBlock>
<Image Margin="11,0,0,0" Source="../Images/edit-48.png"
VerticalAlignment="Center" Width="28" Height="28"
RenderOptions.BitmapScalingMode="HighQuality"/>
</StackPanel>
</DataTemplate>
when i execute above i am having 19 blank items in my combo, as i've 19 hospitals in my db table, not only this even the cmbHospital_OnSelectionChanged is working fine whenever i made another selection from combobox (i am filling departments on selected hospital).
Sub cmbHospital_OnSelectionChanged(ByVal sender As Object, ByVal e As RoutedEventArgs)
FillDepartment(CType(CType(cmbHospital.SelectedItem,
HospitalEntity).Fields("HospitalId").DbValue, Integer))
End Sub
On other hand I am using datatable as the datacontext for Department combobox and which is working fine (displaying departments).
'Code to fill Department Combobox (cmbDepartment)
Private Sub FillDepartment(ByVal p_nHospitalId As Integer)
Dim objSPCalling As New SPCalling
cmbDepartment.DataContext =
objSPCalling.GetHospitalDepartment(p_nHospitalId) 'Return Datatable
End Sub
'Department Combobox XAMAL
<ComboBox Grid.Column="1" Grid.Row="1" VerticalAlignment="Bottom"
Margin="10,0,10,0" Name="cmbDepartment"
IsSynchronizedWithCurrentItem="True"
ItemsSource="{Binding}"
ItemTemplate="{StaticResource DepartmentListTemplate}"
/>
'Department ListTemplate is defined as
<DataTemplate x:Key="HospitalListTemplate">
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Path=strDisplayAs}" Margin="0,0,2,0"
VerticalAlignment="Center"/>
<TextBlock VerticalAlignment="Center">
<Bold><Label Content="{Binding Path=intSort}" /></Bold>
</TextBlock>
<Image Margin="11,0,0,0" Source="../Images/edit-48.png"
VerticalAlignment="Center" Width="28" Height="28"
RenderOptions.BitmapScalingMode="HighQuality"/>
</StackPanel>
</DataTemplate>
Any idea why these hospital items are not getting displayed.
Note: I am using image in both Datatemplates as for my practice.
Regards,