MainPage.xaml
<Page
x:Class="UniversalAppTutorials.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:UniversalAppTutorials"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<StackPanel
x:Name="stack_panel1"
Margin="50"
Orientation="Horizontal"
Background="AliceBlue"
Padding="50"
>
<ComboBox
x:Name="ComboBox1"
SelectionChanged="ComboBox1_SelectionChanged"
Margin="0,100,0,0"
/>
<TextBlock
x:Name="TextBlock1"
Foreground="Crimson"
FontFamily="MV Boli"
FontSize="25"
Text="Select a color from ComboBox."
TextWrapping="WrapWholeWords"
Margin="100,100,0,0"
/>
</StackPanel>
</Page>
MainPage.xaml.cs
using Windows.UI.Xaml.Controls;
namespace UniversalAppTutorials
{
public sealed partial class MainPage : Page
{
public MainPage()
{
this.InitializeComponent();
// Initialize a new string array
string[] colors = {
"Red",
"Green",
"Blue",
"Yellow",
"Snow",
"Gold",
"Forest Green",
"Medium Sea Green"
};
// Specify the ComboBox item source
ComboBox1.ItemsSource = colors;
}
private void ComboBox1_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
// Get the instance of ComboBox
ComboBox comboBox = sender as ComboBox;
// Get the ComboBox selected item text
string selectedItems = comboBox.SelectedItem.ToString();
// Finally, display the ComboBox selected item text to text block
TextBlock1.Text = "Selected : " + selectedItems;
}
}
}




- UWP - Segoe MDL2 Assets font example
- UWP - SplitView example
- UWP - SymbolIcon example
- UWP - How to add a new line to a TextBlock
- UWP - PivotItem header with image and text
- UWP - Simple Pivot example
- UWP - Polygon example
- UWP - Rectangle example
- UWP - ListView multi select example
- UWP - ListView ItemTemplate example
- UWP - ListView HeaderTemplate example
- UWP - How to add margin to each item in a ListView
- UWP - How to add item separator to ListView
- UWP - How to use ListView item click event
- UWP - Horizontal ListView example