Someone has a custom style for the app's button. Now I want to create a custom style based on this custom style. For example, I want to create a "close button" that I want to reuse all other applications. I tried to do this:
& lt; Style x: key = "GlassButtonClose" target type = "button" based on = "{static resources glass button}" & gt; & Lt; Setter property = "horizontal alignment" value = "true" /> & Lt; Setter Estates = "Template" & gt; & Lt; Setter.Value & gt; & Lt; ControlTemplate TargetType = "Button" & gt; & Lt; Grid & gt; & Lt; Grid.ColumnDefinitions & gt; & Lt; Column width = "Auto" /> & Lt; Columns Definition / & gt; & Lt; /Grid.ColumnDefinitions> & Lt; Image grid. Column = "0" grid. Line = "0" source = "/ remaining; components / images / close" width = "24" height = "24" /> & Lt; TextBlock Grid.Column = "1" vertical alignment = "center" text = "{binding source = {static resource populace}, path = buttonBellClose}" margin = "0" /> & Lt; / Grid & gt; & Lt; / ControlTemplate & gt; & Lt; /Setter.Value> & Lt; / Setter & gt; & Lt; / Style & gt;
But this does not hold the GlassButton settings How can I extend the settings to keep existing settings?
Thanks for your help
The template shown in the comments and your answer On the basis it seems that you need a specific glassbutton with a certain icon and text. And you want to use this button without having to specify your content again and again.
Solution: Prepare your own type GlassStyleCloseButton
.
Public Square GlassStyleCloseButton: Button {Public GlassStyleCloseButton () {DefaultStyleKey = typeof (GlassStyleCloseButton); }}
and a style for the new type (can be placed in app.xaml or generic.xaml):
& gt; Style TargetType = "GlassStyleClassButton" based on "= {static resource glassbutton}" & gt; & Lt; Setter Property = "Content" Value = "{Binding Path = ButtonBelclos, Source = {Static Resources People Comments}}" /> & Lt; Setter Property = "Content Template" & gt; & Lt; Setter.Value & gt; & Lt; DataTemplate & gt; & Lt; Grid & gt; & Lt; Grid.ColumnDefinitions & gt; & Lt; Column width = "Auto" /> & Lt; Column width = "*" /> & Lt; /Grid.ColumnDefinitions> & Lt; Image source = "/ Balge; components / images / close" width = "24" height = "24" /> & Lt; Text block grid Column = "1" vertical alignment = "center" text = "{TemplateBinding content}" /> & Lt; / Grid & gt; & Lt; / DataTemplate & gt; & Lt; /Setter.Value> & Lt; / Setter & gt; & Lt; / Style & gt;
And you can use it like this:
& lt; Somewhere I like you & gt; ... & lt; GlassStyleClassButton / & gt; & Lt; / SomewhereInMyApp & gt;
Comments
Post a Comment