WPF打开windows弹窗与关闭以及Window参数为空的处理
//--------Window弹窗与关闭 <DataGridTemplateColumn Header="操作" Width="*"> <DataGridTemplateColumn.CellTemplate> <DataTemplate> <Button Style="{StaticResource CcHotelButtonStyle}" Height="30" Command="{Binding DataContext.ColorSetBtnCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=DataGrid}}">颜色设置</Button> </DataTemplate> </DataGridTemplateColumn.CellTemplate> </DataGridTemplateColumn> private void ExitWindow(Window t) { t.DialogResult = false; t.Close(); } private void ColorSetBtnWindowShow(Window t) { var colorWindow = new HM_RoomColorContainer(); colorWindow.Owner = t; colorWindow.Topmost = true; bool? result = colorWindow.ShowDialog(); if (result!=null&&result.Value) { --- } } //关闭按钮 <StackPanel Grid.Row="0" Orientation="Horizontal" HorizontalAlignment="Right" Margin="0 0 3 0" Grid.Column="4"> <cc:CcHotelButton Style="{StaticResource CcHotelButtonBaseStyle}" ButtonImage="{StaticResource Close}" Grid.Column="4" Command="{Binding CloseWindowForColorCommand, UpdateSourceTrigger=PropertyChanged}" CommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Window}}">关闭</cc:CcHotelButton> </StackPanel>
Window参数为空的处理,按钮在datagrid中
如有疑问或者错误的地方,请跟帖,本人会第一时间答复以及相互学习,谢谢!个人会不断的上传自己的学习心得!
好了今天就先到这里,下次有时间再更新,如果存在不合理的地方,欢迎大家多多指教留言!!!
分类:
WPF
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· AI技术革命,工作效率10个最佳AI工具