在WPF中选择一个网格 [英] Select a Grid in WPF
本文介绍了在WPF中选择一个网格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在WPF中使用网格捕获事件.
解决方案
您将需要将DynamicResources应用于样式.网格样式的一个很好的例子是: http://msdn.microsoft.com/en-us/library/ff506248.aspx [ ^ ]
您只需要使用类似这样的PreviewEvent,
<网格名称= " verticalalignment = " background = " Previewmouseleftbuttondown = " </ >
在后面的代码中,
私有 void TestPreview(对象发件人,MouseEventArgs e) { grid1.Background = Brushes.Blue; }
现在,您可以按照自己的方式进行操作.但我建议您彻底检查RoutedEvent.如果您愿意,可以看一下[ ^ ]
>
How to Catch Event with Grid in WPF.
解决方案
You are going to need DynamicResources applied to the styling. A good example of grid styling is : http://msdn.microsoft.com/en-us/library/ff506248.aspx[^]
You just need to use PreviewEvent Which is Something like that,
<grid name="grid1" verticalalignment="Top" background="AliceBlue" previewmouseleftbuttondown="TestPreview"></grid>
And on the code behind,
private void TestPreview(object sender, MouseEventArgs e) { grid1.Background = Brushes.Blue; }
Now you can do it in your own way. But i would suggest you to look on to the RoutedEvent thoroughly. If you want you might have a look on that [^]
这篇关于在WPF中选择一个网格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文