-1
私のアプリケーションにはコンボボックスコントロールがあります。私はそれを使用して、データベースで定義された状態のリストから状態を選択します。選択された値は、ユーザークラスの状態フィールド(a)に値を割り当てるために使用する必要があります(データベースにユーザーデータを保持するテーブルがあります)。複数のDataContextへのコンボボックスのバインド
XAML:背後に
<StackPanel x:Name="stckDetails">
<TextBox Margin="10,5,10,5" Text="{Binding FirstName, Mode=TwoWay}"/>
<TextBox Margin="10,5,10,5" Text="{Binding LastName, Mode=TwoWay}"/>
<ComboBox Margin="10,5,10,5" ItemsSource = "{Binding Register.States}" Text="{Binding State, Mode=TwoWay}"/>
</StackPanel>
コード:
class Register
{
public User newUser;
public ObservableCollection<string> States { get; set; }
public Register()
{
newUser = new User();
States = new ObservableCollection<string> { "CH", "MA", "KL", "FL" };
stckDetails.DataContext = newUser;
}
}
public class User
{
public int UserId { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public string State {get; set; }
}
私は別のDataContextにコンボボックスの異なる特性をバインドするにはどうすればよいです。出来ますか ?構文私はdoesntの仕事を使用しています。
。 – BlackMask