• xaml页面和viewmodel之间接收绑定的参数,也可以称为事件里动态传入用户自定义参数


    //xaml代码,高亮部分就是向绑定层动态传入参数
    <controls:UserControl1
        x:Name="pg"
        Grid.Row="3"
        Margin="0,10,0,10"
        HorizontalAlignment="Center"
        IsResultDisplay="True"
        PageSize="{Binding PageSize, Mode=TwoWay}"
        TotalCount="{Binding TotalCount, Mode=TwoWay}"
        Visibility="Visible"
        PageIndex="{Binding PageIndex, Mode=TwoWay, NotifyOnTargetUpdated=True}">
        <i:Interaction.Triggers>
            <i:EventTrigger EventName="PagerIndexChanged">
                <i:InvokeCommandAction Command="{Binding PagerIndexChangedCommand}" CommandParameter="{Binding ElementName=pg, Path=PageIndex, Mode=TwoWay}" />
            </i:EventTrigger>
        </i:Interaction.Triggers>
    </controls:UserControl1>
            
    
    //viewmodel代码,int? p就是页面传入的参数
    public ICommand PagerIndexChangedCommand { get { return new DelegateCommand<int?>(p => PagerIndexChanged(p)); } }
    
    void PagerIndexChanged(int? index)
    {
    
    }
  • 相关阅读:
    【ccf线上赛普及组 2020】
    【小总结】2020.3.6
    DP优化
    noip2012day2
    noip2012day1
    3.28真题
    数据结构总结
    noi online 普及组
    小总结
    20200229模拟赛
  • 原文地址:https://www.cnblogs.com/zsx-blog/p/13415276.html
Copyright © 2020-2023  润新知