• WPF


    转:http://www.cnblogs.com/mantian/p/3713524.html

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

    解决方法:

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

    1
    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>
    复制代码
  • 相关阅读:
    JS——祝愿墙
    JS——模拟百度搜索
    JS——选择水果
    html——快捷键
    JS——百度背景图
    JS——stye属性
    JS——高级各行换色
    html——细线表格
    LeetCode初级算法(数组)解答
    Python网络爬虫(四)
  • 原文地址:https://www.cnblogs.com/xcsn/p/4485737.html
Copyright © 2020-2023  润新知