单击按钮可更改 WPF 中带有触发器的 DataGrid 的可见性
您好,我正在尝试找到某种方法,当单击按钮时会更改其他控件的可见性,例如 XAML 中带有触发器的 DataGrid。
该按钮仅将 DataGrid 的可见性更改为可见,它在代码隐藏中执行其他操作,但我认为这可以在带有触发器的样式中完成。
我试图找到解决方案,似乎可以做到,但我不明白如何做。
提前致谢。
Hi i am trying to find some way to when a button is clicked changes the visibility of other control, like a DataGrid with a Trigger in XAML.
The button only changes the visibility of the DataGrid to Visible, it does other things in Code Behind, but this is something that i think that can be done in a Style with a Trigger.
I tried to find a solution and it seems to be possible to do but i can't understand how.
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
{x:Reference dataGrid}
引用名为dataGrid
的 DataGrid,或者您也可以只使用Storyboard.TargetName
。如果您要绑定或引用资源,通常会使用Storyboard.Target
属性。{x:Reference dataGrid}
references a DataGrid with the namedataGrid
, alternatively you could just useStoryboard.TargetName
. You would normally use theStoryboard.Target
property if you do binding or references to resources.只是一个建议,但是为了更容易理解,有一个启用/禁用 DataGrid 显示的复选框怎么样?这就是我通常做的事情:
当然,您必须实现适当的转换器
Just a suggestion, but how about, for something more understandable, having a Checkbox enabling/disabling the DataGrid display? This is what I usually do:
And of course, you'll have to implement the appropriate converter