Replies: 1 comment 2 replies
-
<Style TargetType="local:MyButton">
<Setter Property="Background" Value="SlateBlue" />
<Setter Property="BorderBrush" Value="Gray" />
<Setter Property="BorderThickness" Value="1" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="local:MyButton">
<Button Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="5">
<Button.Content>
<StackPanel Orientation="Vertical"
VerticalAlignment="Center"
HorizontalAlignment="Center">
<SymbolIcon Symbol="{TemplateBinding ButtonSymbol}"
Margin="0,0,0,10" />
<TextBlock Text="{TemplateBinding ButtonText}" />
</StackPanel>
</Button.Content>
</Button>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style> The setters are now the source for the <Style x:Key="MyButtonStyle" TargetType="Button">
<Setter Property="Background" Value="SlateBlue" />
<Setter Property="BorderBrush" Value="Gray" />
<Setter Property="BorderThickness" Value="1" />
<Setter Property="Width" Value="100" />
<Setter Property="Height" Value="100" />
</Style>
<Style TargetType="local:MyButton">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="local:MyButton">
<Button Style="{StaticResource MyButtonStyle}"
CornerRadius="5">
<Button.Content>
<StackPanel Orientation="Vertical"
VerticalAlignment="Center"
HorizontalAlignment="Center">
<SymbolIcon Symbol="{TemplateBinding ButtonSymbol}"
Margin="0,0,0,10" />
<TextBlock Text="{TemplateBinding ButtonText}" />
</StackPanel>
</Button.Content>
</Button>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style> Now the source of those properties is the
<Button Content="Hello" Background="{x:Null}" /> Basically the difference between |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I don't know how to title this question because it includes two "issues-ish".
First and foremost, IS'T NOT A Uno ISSUE because it happens on Windows too, but if anyone knows why it behaves this way I'd like to know it.
Scenario:
I am working on a Templated control, it's a Button which content is a
SymbolIcon
and aTextBlock
below it.This is the template:
MainPage:
First thing I notice is that properties included in
MyButtonStyle
withTemplateBinding
are never applied. ThereforeBackground, BorderThickness and BorderWidth
have no value, onlyWidth and Height
are included.Now the most curious thing, the Button without Background, not having been applied by the
Style
, does not respond to pointer events unless you click on some of the UIElements of its content. If you set aBackground
, even if it isTransparent
, it behaves like any other button.The questions should be:
1- Why style properties are not applied?
2- Why is it not responding to pointer events?
I added a minimum example if anyone want to try it.
Thanks.
TestControlStyle.zip
Beta Was this translation helpful? Give feedback.
All reactions