• 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>
  • 相关阅读:
    P2761 软件补丁问题
    CF1335F Robots on a Grid
    [bzoj2088]P3505 [POI2010]TEL-Teleportation
    CF1335E Three Blocks Palindrome
    P3831 [SHOI2012]回家的路
    P4568 [JLOI2011]飞行路线(分层图)
    P4774 [NOI2018]屠龙勇士
    P2480 [SDOI2010]古代猪文
    CF #632 (Div. 2) 对应题号CF1333
    BSGS 和扩展
  • 原文地址:https://www.cnblogs.com/mantian/p/3713524.html
Copyright © 2020-2023  润新知