Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Ioana, I don't seem to get what you're aiming at..<br> if you take this xaml:</p> <pre><code>&lt;Window x:Class="WpfApplication4.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Window1" Height="300" Width="300"&gt; &lt;StackPanel&gt; &lt;TextBox Text="{Binding Path=SelectedText, Mode=TwoWay}" Width="200"/&gt; &lt;ComboBox Width="200" VerticalAlignment="Center" HorizontalAlignment="Center" SelectedItem="{Binding Path=SelectedText, Mode=TwoWay}" ItemsSource="{Binding Path=Texts, Mode=OneWay}"&gt; &lt;/ComboBox&gt; &lt;/StackPanel&gt; &lt;/Window&gt; </code></pre> <p>and this codebehind:</p> <pre><code> public partial class Window1 : INotifyPropertyChanged { public Window1() { InitializeComponent(); this.Texts = new List&lt;string&gt;(new[] {"foo","bar"}); this.DataContext = this; } private ObservableCollection&lt;string&gt; texts; public ObservableCollection&lt;string&gt; Texts { get { return texts; } set { texts = value; if (this.PropertyChanged != null) this.PropertyChanged(this, new PropertyChangedEventArgs("Texts")); } } private string selectedText; public string SelectedText { get { return selectedText; } set { selectedText = value; if (this.PropertyChanged != null) this.PropertyChanged(this, new PropertyChangedEventArgs("SelectedText")); } } public event PropertyChangedEventHandler PropertyChanged; } </code></pre> <p>You do have the Items and the selectedValue databound.<br> Notice the <em>INotifyPropertyChanged</em>.<br> Is this what you're trying to achieve ?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload