c# - Global style and local style overriding global style under same control -


I have a default style that is declared in the DefaultTheme.xaml file for TypeMenu items

  & lt; Style target type = "{x: type menu item}" & gt; . . . & Lt; / Style & gt;   

It was merged into user control

  & lt; ResourceDictionary Merged Dictionary & gt; & Lt; Source source = "../defaultTheme.xaml" /> & Lt; /ResourceDictionary.MergedDocs> Now in user control, if I declare any style for  TargetType = "{x: Type MenuItem}" , then it handles styles declared from the global style.  

e.g.

  & lt; Style x: key = "local style" target type = "{x: type menu item}" & gt; . . . & Lt; / Style & gt;   

This will also apply the global style. I do not want this local style to inherit the global style. So I have the & lt; Style TargetType = "{x: Type MenuItem}" & gt; .. & lt; / Style & gt; I can override it by giving .

Hold here, if I do this, then I can not apply to other places in global control because I have overridden it locally. How should this be controlled?

Based on this, your description is something reverse. Since the local style was not inherited from the base, the original style would not be applied to the local.

If I do this then I will not be able to apply global style to other places in the control because I have overridden it locally

It will not happen, because the local style was declared with a key and it will be applied to MenuItem where the key is referenced. Everyone else is applied with the global style.

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -