C#, C♯, C#相談室 Part91at TECH
C#, C♯, C#相談室 Part91 - 暇つぶし2ch90:デフォルトの名無しさん
16/11/09 04:29:27.99 9orsc4MQ.net
>>86
>>87
業務で使う場合はViewとViewModelをきっちり分けるよ
なのでバインディング式は下記のように
<TextBox Text={Binding ResultMessage} />
シンプルになる。
View内の他の要素の値をバインドするなんて
滅多にないから(デバッグ時くらい?)、{Binding ElementName=slider1, Path=Value}
みたいな冗長な書き方はいいと思う。
装飾系も普通はResourceDictionaryにまとめる。TextBoxタグ内にゴテゴテ書いたりしない
<Window.Resources>
 <ResourceDictionary>
  <Style TargetType="TextBox">
   <Setter Property="VerticalContentAlignment" Value="Center" />
   <Setter Property="HorizontalAlignment" Value="Left" />
   <Setter Property="Foreground" Value="{StaticResource GlobalForeground}" />
  </Style>
 </ResourceDictionary>
</Window.Resources>
キー押下時のイベント発生もViewはCommandをViewModelに発行するだけだね
<Window.InputBindings>
 <KeyBinding Gesture="Ctrl+T" Command="{Binding MenuOpenCommand}" />
</Window.InputBindings>
イベント発生時の処理内容をxaml.csに記述したりはしない


次ページ
続きを表示
1を表示
最新レス表示
レスジャンプ
類似スレ一覧
スレッドの検索
話題のニュース
おまかせリスト
オプション
しおりを挟む
スレッドに書込
スレッドの一覧
暇つぶし2ch