<ComboBox Canvas.Left="92" Canvas.Top="150"
		Header="My Combo Box" 
	//----- SET UP COMBO BOXES -----
	MyComboBox.SelectedIndex = 0;

Styled Example

  <ComboBox Canvas.Left="92" Canvas.Top="150" x:Name="MyComboBox" Style="{StaticResource cmbSetupRelays}" />
In App.xaml
        <!-- COMBO BOX SETUP RELAYS -->
        <Style x:Key="cmbSetupRelays" TargetType="ComboBox">
            <Setter Property="Width" Value="178" />
            <Setter Property="Height" Value="28" />
            <Setter Property="Background" Value="LightGray" />
            <Setter Property="Foreground" Value="#460000"/>
            <Setter Property="BorderBrush" Value="{ThemeResource SystemControlForegroundTransparentBrush}" />
            <Setter Property="BorderThickness" Value="{ThemeResource ButtonBorderThemeThickness}" />
            <Setter Property="Padding" Value="0,0,0,0" />
            <Setter Property="HorizontalAlignment" Value="Center" />
            <Setter Property="VerticalAlignment" Value="Center" />
            <Setter Property="FontFamily" Value="Arial" />
            <Setter Property="FontWeight" Value="Bold" />
            <Setter Property="FontSize" Value="13" />
            <Setter Property="UseSystemFocusVisuals" Value="True" />

Function call

<ComboBox Canvas.Left="92" Canvas.Top="150" x:Name="MyComboBox" SelectionChanged="EditComboBox_SelectionChanged" />
	private async void EditComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
			//Get combobox name
			var PageObject = sender as ComboBox;

			// = PageObject.SelectedIndex;

		catch (Exception ex)
			System.Diagnostics.Debug.WriteLine("Exception: " + ex.Message);
We benefit hugely from resources on the web so we decided we should try and give back some of our knowledge and resources to the community by opening up many of our company’s internal notes and libraries through mini sites like this. We hope you find the site helpful.
Please feel free to comment if you can add help to this page or point out issues and solutions you have found, but please note that we do not provide support on this site. If you need help with a problem please use one of the many online forums.


Your email address will not be published.