Silverlight は初めてで、MVVM パターンを使用して RIA サービス経由でフォームをデータベースに保存しようとしています。
バインド モードでテキスト ボックスを文字列にバインドすると、ViewModel でテキスト ボックスの値を取得しtwoway
ます。
しかしObject.Property
、テキスト ボックス (双方向バインディング) にバインドすると、保存ボタンをクリックした後、ViewModel にnull オブジェクトが表示されます。
これが私のコードです。どこが間違っているのかを理解してください。
private tblSchool _school;
public tblSchool thisschool
{
get
{
return _school;
}
set
{
if (_school != value)
{
_school = value;
OnPropertyChanged("thisschool");
}
}
}
private void SaveSchool()
{
DomainServiceForDatabaseData service = new DomainServiceForDatabaseData();
service.tblSchools.Add(thisschool); //HERE I GET NULL VALUE
service.SubmitChanges();
}
ここに私のXAMLがあります:
<Grid x:Name="LayoutRoot"
DataContext="{Binding Source={StaticResource SignUpViewModel}}">
<TextBox Height="23"
HorizontalAlignment="Right"
Margin="0,55,160,0"
Name="textBox1"
VerticalAlignment="Top"
Width="213"
Text="{Binding Path= thisschool.School_Name, Mode=TwoWay}" />