-
April 27th, 2018, 08:34 AM
#1
ControlTemplate - Border set CornerRadius
Hi,
I've a content control with a Border inside. I have to use this control to make different corner radius in a toggle button control (only left corner, center and right corner). To do this I've make 3 differente controltemplate because the CornerRadius of border don't accept a TemplateBinding for that.
It's possible to make an unique controltemplate and passing the corner radius as TemplateBinding?
Thanks
-
July 1st, 2019, 01:33 AM
#2
Re: ControlTemplate - Border set CornerRadius
<Window.Resources>
<Style x:Key="TabButton" TargetType="Button">
<Setter Property="TextBlock.TextAlignment" Value="Center" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding Background}"
BorderThickness="0,1,1,0"
CornerRadius="{TemplateBinding Border.CornerRadius}">
<ContentPresenter
x:Name="contentPresenter"
Margin="{TemplateBinding Padding}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
Content="{TemplateBinding Content}"
ContentTemplate="{TemplateBinding ContentTemplate}" />
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style
x:Key="TabButtonFirst"
BasedOn="{StaticResource TabButton}"
TargetType="Button">
<Setter Property="Border.CornerRadius" Value="15,0,0,0" />
</Style>
<Style
x:Key="TabButtonLast"
BasedOn="{StaticResource TabButton}"
TargetType="Button">
<Setter Property="Border.CornerRadius" Value="0,0,0,15" />
</Style>
</Window.Resources>
<StackPanel>
<Button
Width="200"
Height="30"
Content="test" Style="{StaticResource TabButtonFirst}"/>
<Button
Width="200"
Height="30"
Content="test" Style="{StaticResource TabButtonLast}"/>
</StackPanel>
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|