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)
Open default email app in .NET MAUI
Sample Code: if (Email.Default.IsComposeSupported) { string subject = "Hello!"; string body = "Excellent!"; ...
-
HttpClient is a .NET class that an app can use to send HTTP requests and receive HTTP responses from a REST web service. The resources that...
-
Grid is a layout panel that consists of rows and columns. Example 1: < Grid > < Grid.RowDefinitions > < Row...
-
Label tb = new Label (); tb.Name = "LabelID" + iRow; tb.Content = lblName; Grid .SetColumn(tb, iCol); Grid .SetRow(tb,...
No comments:
Post a Comment