zoukankan      html  css  js  c++  java
  • 【转】【WPF】WPF

    将所有的事件,属性,都映射到ViewModel中。好处多多,以后开发尽量用这种模式。

    解决方法:

    使用System.Windows.Interactivity.dll,添加该dll到项目引用

    xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"

    ComboBox映射的代码:

    <ComboBox VerticalAlignment="Center" HorizontalAlignment="Left" MinWidth="120" Margin="10,0,0,0"
                                  x:Name="cboTest" 
                                  DisplayMemberPath="FamilyName"  
                                  SelectedValuePath="IdFamily" 
                                  IsReadOnly="True"
                                  ItemsSource="{Binding ListFamily}"
                                  SelectedValue="{Binding Path=ViewModel.SelectedFamilyNameID, Mode=TwoWay, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type UserControl}}}"
                                  Validation.ErrorTemplate="{x:Null}"
                                  Visibility="{Binding ComboBoxVisibility}"
                                  >
                                <i:Interaction.Triggers>
                                    <i:EventTrigger EventName="SelectionChanged">
                                        <i:InvokeCommandAction Command="{Binding FamilySelectionChangedCommand}"   
                                                           CommandParameter="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}},Path=DataContext}"/>
                                    </i:EventTrigger>
                                </i:Interaction.Triggers>
                            </ComboBox>

    原文地址:https://www.cnblogs.com/mantian/p/3713524.html

  • 相关阅读:
    博客园的界面设置
    ARM 汇编指令集
    winfroms更换皮肤
    面向对象的七项设计原则
    S2-01
    机票查询与订购系统
    重点语法
    第二章
    一、17.09.13
    习作
  • 原文地址:https://www.cnblogs.com/mqxs/p/9588485.html
Copyright © 2011-2022 走看看