继承样式或以编程方式查找样式
我有一个第三方控件,我认为它从某个地方获取了样式。 我有该控件的一个子类,我在其中添加了一个事件处理程序。但现在,当我用重写的控件替换 xaml 中的旧控件时,样式就会丢失。我假设它在应用样式时区分超类和子类。我如何告诉它子类(如 MyButton:ThirdPartyButton)应具有与 ThirdPartyButton 相同的样式。
或者是否有一种编程方式来查看样式的来源,例如
ThirdPartyButton.GetDefaultStyleLocation();
I have a third party control that I assume gets a style from somewhere.
I have an subclass of that control, where I add an event handler. but now when I replace the old control in xaml with my overrided control, the style gets lost. I assume that its distinguishing between the superclass and subclass when it applies the style. How do I tell it that subclasses, like MyButton:ThirdPartyButton, should have the same style as ThirdPartyButton.
Or is there a programmatic way to see the source of the style like
ThirdPartyButton.GetDefaultStyleLocation();
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在隐式应用的资源中定义一个样式:
这是必要的,因为遗憾的是样式不能被继承。
Define a style in the resources which is implicitly applied:
This is necessary since styles are sadly not inherited.