私は学習catel mvvm frameworkですが、なんらかの理解上の問題があります。 catelフレームワークを使用して、シンプルなプロジェクトを簡単に構築しようとしています。 は、その後のviewmodelシンプルなcatel dependency injectionのやり方
public class FirstViewModel : ViewModelBase
{
public FirstViewModel(First first)
{
Argument.IsNotNull(() => first);
First = first;
}
[Model]
public First First
{
get { return GetValue<First>(TestModelProperty); }
private set { SetValue(TestModelProperty, value); }
}
public static readonly PropertyData TestModelProperty = RegisterProperty("TestModel", typeof(First));
[ViewModelToModel("First")]
public String FirstValue
{
get { return GetValue<String>(FirstValueProperty); }
set { SetValue(FirstValueProperty, value); }
}
public static readonly PropertyData FirstValueProperty = RegisterProperty("FirstValue", typeof(String));
[ViewModelToModel("First")]
public String SecondValue
{
get { return GetValue<String>(SecondValueProperty); }
set { SetValue(SecondValueProperty, value); }
}
public static readonly PropertyData SecondValueProperty = RegisterProperty("SecondValue", typeof(String));
}
は、最後のビュー
<catel:StackGrid>
<catel:StackGrid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</catel:StackGrid.RowDefinitions>
<catel:StackGrid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</catel:StackGrid.ColumnDefinitions>
<Label Content="First value" />
<TextBox Text="{Binding FirstValue}" TextAlignment="Center" Width="100"/>
<Label Content="Second value" />
<TextBox Text="{Binding FirstSecond}" TextAlignment="Center" Width="100"/>
</catel:StackGrid>
とウィンドウ
012を使用してサービスpublic class FirstService : IFirstService
{
public First Read()
{
return new First();
}
public First Write(First first)
{
first.SecondValue = first.FirstValue;
return first;
}
}
を持っているモデル
public class First : ModelBase
{
public String FirstValue
{
get { return GetValue<String>(FirstValueProperty); }
set { SetValue(FirstValueProperty, value); }
}
public static readonly PropertyData FirstValueProperty = RegisterProperty("FirstValue", typeof(String), "First Text");
public String SecondValue
{
get { return GetValue<String>(SecondValueProperty); }
set { SetValue(SecondValueProperty, value); }
}
public static readonly PropertyData SecondValueProperty = RegisterProperty("SecondValue", typeof(String), "Second text");
}
を持っています
<catel:StackGrid x:Name="LayoutRoot">
<catel:StackGrid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</catel:StackGrid.RowDefinitions>
<Label Content="{Binding Title}" />
<views:FirstView />
<Button Content="Write" Command="{Binding WriteFirst}" Width="70" />
</catel:StackGrid>
どのようにsipmle catel dependency injectionを実行するかは、両方のテキストボックスの開始アプリケーションでは、ファーストクラスのデフォルトデータでした。また、Writeボタンを押すと、誰かが最初のテキストボックスに入力した人物を、サービスを使用して2番目のテキストボックスにコピーすることができます。私は例でこれをやろうとしていますcatelのドキュメントから始めましょう。しかし、働かないでください。