Following sample will show how to databind in WPF ComboBox
Following code goes into your xaml file
----------------------------------------------------------------------------------------
<ComboBox Name="comboBox1" Grid.Row="1" Grid.Column="2" SelectionChanged="comboBox1_DropDownClosed"
DataContext="Binding ElemntName=LanguageListBinding,Path=SelectedItem" FontSize="13" Height="20" >
<ComboBox.ItemTemplate>
<DataTemplate>
<StackPanel Name="spSitePanel" Orientation="Horizontal">
<TextBlock Visibility="Hidden" Width="0" x:Name="txtSiteID" Text="{Binding Path=LanguageID}" />
<TextBlock x:Name="txtSiteName" Text="{Binding Path=Language}" />
</StackPanel>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
---------------------------------------------------------------------------------------------------------
following code goes into codebehind of xaml file (cs file)
public static localhost1.MyClass g_ProxyWebService;
g_ProxyWebService = new localhost1.MyClass();
... ......... .......... ...........
... ......... .......... ...........
Binding LanguageListBinding = new Binding();localhost1.clsUser[] objProtocol = g_ProxyWebService.GetLanguageList();
LanguageListBinding.Source = objProtocol;
comboBox1.SetBinding(ComboBox.ItemsSourceProperty, LanguageListBinding);
comboBox1.SelectedIndex = 0;
----------------------------------------------------------------------------------------------------
Subscribe to:
Post Comments (Atom)
If you’re using Visual Studio to build your .NET MAUI app on a Mac, locating the IPA (iOS App Package) file can be a bit tricky
If you’re using Visual Studio to build your .NET MAUI app on a Mac , locating the IPA (iOS App Package) file can be a bit tr...
-
Sample Code: if (Email.Default.IsComposeSupported) { string subject = "Hello!"; string body = "Excellent!"; ...
-
If you’re using Visual Studio to build your .NET MAUI app on a Mac , locating the IPA (iOS App Package) file can be a bit tr...
-
Charts for Windows and web including .Net MAUI LiveCharts - LiveCharts2 (lvcharts.com)
No comments:
Post a Comment