WPF 小知识点001

1.DataGrid 单选事件

 <DataGrid MinHeight="150"
                  AutoGenerateColumns="False"
                  CanUserAddRows="False"
                  IsReadOnly="True"
                  ItemsSource="{Binding DBG_ReserveData}"
                  SelectedItem="{Binding TCmsReserveNet}"
                  SelectionMode="Single">

 <!-- *** -->

</DataGrid>

下面文本框中上一级菜单绑定DataSource 或者DataContent 绑定TCmsReserveNet,文本框绑定到里面的属性;

2.不用SelectedItem

 <i:Interaction.Triggers>
                <i:EventTrigger EventName="SelectionChanged">
                    <i:InvokeCommandAction Command="{Binding SelectedCmsReserveCommand}" />
                </i:EventTrigger>
            </i:Interaction.Triggers>

SelectedCmsReserveCommand:

复制代码
  public ICommand SelectedCmsReserveCommand
        {
            get
            {
                return new RelayCommand<string>(parameter =>
                {
                    if (DBG_ReserveData.CurrentItem != null)
                    {
                        //获取当前选中列
                        t_cms_reserveNet seCmsReserveNet = (t_cms_reserveNet)DBG_ReserveData.CurrentItem;

                        fGuestName = seCmsReserveNet.GN;
                        fBeginTime = seCmsReserveNet.BT;
                        fEndTime = seCmsReserveNet.ET;
                        fPhone = seCmsReserveNet.P;
                        fManagerID = seCmsReserveNet.MID;

                        fMoneyState = seCmsReserveNet.MS;
                        fNote = seCmsReserveNet.N;
                        fReserveState = seCmsReserveNet.RS;
                        fRoomTypeID = seCmsReserveNet.RTID;
                        fRoomID = seCmsReserveNet.FRID;

                        fSubscription = seCmsReserveNet.ST;
                        mTCmsReserve.fReserveID = seCmsReserveNet.RID;
                    }
                });
            }
        }
View Code
复制代码

 

posted @   maanshancss  阅读(138)  评论(0编辑  收藏  举报
编辑推荐:
· 使用 .NET Core 实现一个自定义日志记录器
· [杂谈]如何选择:Session 还是 JWT?
· 硬盘空间消失之谜:Linux 服务器存储排查与优化全过程
· JavaScript是按顺序执行的吗?聊聊JavaScript中的变量提升
· [杂谈]后台日志该怎么打印
阅读排行:
· 2000 Star,是时候为我的开源项目更新下功能了
· 面试官:DNS解析都整不明白,敢说你懂网络?我:嘤嘤嘤!
· [WPF UI] 为 AvalonDock 制作一套 Fluent UI 主题
· 基于.NET WinForm开发的一款硬件及协议通讯工具
· 内网穿透之http代理服务器
点击右上角即可分享
微信分享提示