我重新设计了一个DataGrid,它变得相当复杂,所以我移动了样式(DataGrid,DataGridCell,DataGridRow,.)到一个ResourceDictionary。我给了他们一个x:Key,并将他们引用为DataGrid.RowStyle="{StaticResource SuperRowStyle}“。现在,我也想在行上使用EventSetter,但是显然我不能在ResourceDictionary中设置它,但是也不能在窗口中设置它,因为它被RowStyle属性覆盖。我该怎么做?比尔,丹尼尔
发布于 2018-04-28 06:51:53
我会自己回答,因为在评论中提供了一个很好的解决方案。我在窗口中创建了一个样式,在其中我需要EventSetter,并使用带有所需样式的BasedOn。
发布于 2018-04-12 14:48:51
现在我也想在行上使用
EventSetter,但是很明显,我不能在ResourceDictionary中设置它。
是的,您可以向ResourceDictionary添加代码隐藏文件:
Is it possible to set code behind a resource dictionary in WPF for event handling?
必须在与EventSetter相同的类中定义处理程序。
https://stackoverflow.com/questions/49799372
复制相似问题