How can I select the item of a combobox that I have defined in XAML through binding?
For example, I have a combobox:
<ComboBox x:Name="cboPayFrequency" Grid.Column="4" Grid.Row="7" Tag="c" Style="{StaticResource ShadedComboBox}" SelectedValue="{Binding Path=PayFrequency, Converter={StaticResource payFrequencyConverter}}" VerticalAlignment="Center">
<ComboBoxItem>
<StackPanel Orientation="Horizontal">
<TextBlock Foreground="Green" Text="{x:Static p:Resources.Weekly}" />
</StackPanel>
</ComboBoxItem>
<ComboBoxItem>
<StackPanel Orientation="Horizontal">
<TextBlock Foreground="Blue" Text="{x:Static p:Resources.BiWeekly}" />
</StackPanel>
</ComboBoxItem>
<ComboBoxItem IsSelected="True">
<StackPanel Orientation="Horizontal">
<TextBlock Foreground="Orange" Text="{x:Static p:Resources.Monthly}" />
</StackPanel>
</ComboBoxItem>
<ComboBoxItem>
<StackPanel Orientation="Horizontal">
<TextBlock Foreground="Red" Text="{x:Static p:Resources.SemiMonthly}" />
</StackPanel>
</ComboBoxItem>
<ComboBoxItem>
<StackPanel Orientation="Horizontal">
<TextBlock Foreground="YellowGreen" Text="{x:Static p:Resources.Quarterly}" />
</StackPanel>
</ComboBoxItem>
<ComboBoxItem>
<StackPanel Orientation="Horizontal">
<TextBlock Foreground="Purple" Text="{x:Static p:Resources.SemiAnnually}" />
</StackPanel>
</ComboBoxItem>
<ComboBoxItem>
<StackPanel Orientation="Horizontal">
<TextBlock Foreground="HotPink" Text="{x:Static p:Resources.Annually}" />
</StackPanel>
</ComboBoxItem>
</ComboBox>
But each combobox item is actually just a stackpanel with a textbox. I did that because I wanted each item to be a different color to stand out, but how can I actually select one of those values through binding?
Thanks