Colleagues,
I would like to pre-set the ComboBox in XAML. For example, there are 3 options: “4800”, “9600”, “19200”. I know that the text of the pre-selected item is “9600”. Which properties of ComboBox should I assign? Is it possible to do it entirely in XAML without writing code for looking up the index from the item text.
So far, I’ve tried this:
Code:
<ComboBox Name="cboBaudRate"
Grid.Column="1" Grid.Row="1" Margin="0,2,0,0" HorizontalAlignment="Left" Width="72" Height="20" VerticalAlignment="Top"
SelectedItem="9600" IsSynchronizedWithCurrentItem="True"
ItemsSource="{Binding Source={StaticResource SerialPortOptions}, XPath=./BaudRates/BaudRate }" />
But it keeps selecting the 1st option “4800”, probably because the index is initially set to 0.
Suggestions, insight, references are much appreciated.
- Nick