开发者

ChildWindow Styling Problems

I'm having a couple of major issues when trying to style the ChildWindow control from the SDK.

First issue:

ChildWindow doesn't pick up implicit styles. I understand why, it's because the actual child window is always a derived class.

I know that I can just use an explicit style instead and that's my current solution, but is there any other way to work around this problem so that I don't have to remember to explicitly tag all child windows with the same common style?

Second issue:

We're using Prism 4 and I have a child window instance in a module that is loaded dynamically by the Prism infrastructure. It picks up the explicit child window style, but it doesn't pick up any other implicit styles defined in the shell's App.xaml (such as the TextBox control template).

This only appears to be a problem inside dynamic modules, it's fine with shell-based 开发者_如何学Gowindows. Any ideas why this is happening and what I can do to fix it?


For your first issue, are you targeting ChildWindow to style a derived one? If so, you need to specified the derived type for the TargetType so that the implcicit style can kick in.

As for your second issue, I am not 100% sure how to fix this but what we found out is that if you declare your implicit styles inside the main window's resources, it will be applied to the controls that reside in your external modules. But I think that this was not working for explicit styles though...


Turns out that Prism wasn't the problem - there were implicit styles defined in the child windows that were wiping out the implicit styles from the shell because they weren't using BasedOn. After adding this attribute everything works fine now.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜