Pre-setting the ComboBox selection in XAML
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: Pre-setting the ComboBox selection in XAML

Threaded View

  1. #1

    Resolved Pre-setting the ComboBox selection in XAML

    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
    Last edited by kender_a; January 22nd, 2010 at 02:57 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center