jeudi 4 mai 2017

Assigning AutomationIds to a UWP ComboBox

I've seen some related WPF examples, but I'm having problems assigning automationIds to the items in a UWP ComboBox. This example XAML - Automation ID for ComboBox elements in DataGridComboBoxColumn uses EditingElementStyle, but I don't see intellisense autocomplete that in my XAML code.

<ComboBox x:Name="SampleComboBox" ItemsSource ="{Binding SampleList}" 
AutomationProperties.AutomationId="SampleReason" SelectionChanged="Sample_OnSelectionChanged"
Height="40" Width="120" FontSize="18"  BorderBrush="#cccccc" BorderThickness="1"  
Background="White" Margin="0 0 2 0"  VerticalAlignment="Bottom"></ComboBox>

Where the SampleList as the data source is defined in the viewmodel as

SampleList = null;
 string[] sampleTypes =
 {
      _screenText.GetString("SampleText1/Text"),
      _screenText.GetString("SampleText2/Text")
 };
 SampleList = new ObservableCollection<string>(sampleTypes);

Aucun commentaire:

Enregistrer un commentaire