xaml - Style inheritance - how to refine a custom default style? -
in winrt / uwp app (the problem occurs on both platforms), can define style applies instances of control, omitting x:key
attribute, e.g.:
<style targettype="button"> <setter property="width" value="400"/> </style>
now, i'd apply properties buttons in addition default style:
<style targettype="button" x:key="tallbuttonstyle" basedon="..."> <setter property="height" value="100"/> </style>
the problem is: fill in basedon
attribute, style inherits default style defined above?
in wpf, following:
<style targettype="button" x:key="..." basedon="{staticresource {x:type button}}">
however, x:type
not available on winrt / uwp. this answer suggests, need assign x:key
default style in order able inherit it:
<style targettype="button" x:key="widebuttonstyle"> <setter property="width" value="400"/> </style> <style targettype="button" x:key="tallbuttonstyle" basedon="{staticresource button}"> <setter property="height" value="100"/> </style>
however, in case widebuttonstyle
not used default more, , i'd need apply style="{staticresource widebuttonstyle}"
buttons manually, seams unneessary overhead me.
is there way, either
- set style's
basedon
attribute point respective control's default style, or - set style contains
x:key
attribute used standard controls of given type?
btw, this related topic not answer question, shows how override default style defined in winrt / uwp platform, not custom-made default style.
you can give default style x:key
, make empty style without x:key
based on style. style apply instances of control "reference" first style. can create additional styles based on first style x:key
. not elegant solution think cannot better.
Comments
Post a Comment