ControlTemplate - Border set CornerRadiusAsk Questions

 Posted on 11/13/2019


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?


Share On: facebook gplus twitter
Asked by Steve Summit on 11/13/2019 Score: 52 points
Add Comment:


1 Answers

0 Corrected Answers
Aproved Answers
Answered by Will Smith on 11/13/2019 7:43:13 AM Score: 54 points

<Style x:Key="TabButton" TargetType="Button">
<Setter Property="TextBlock.TextAlignment" Value="Center" />
<Setter Property="Template">
<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}" />
BasedOn="{StaticResource TabButton}"
<Setter Property="Border.CornerRadius" Value="15,0,0,0" />

x:Key="TabButtonLast" BasedOn="{StaticResource TabButton}" TargetType="Button">
<Setter Property="Border.CornerRadius" Value="0,0,0,15" />
<Button Width="200" Height="30" Content="test" Style="{StaticResource TabButtonFirst}"/>
<Button Width="200" Height="30" Content="test" Style="{StaticResource TabButtonLast}"/>


Add Comment:

Post Your Answers

Existing Members

Sign in to your account
Email Address
New Member?
Sign up and complete profile
Full Name
Email Address
I have read and agree to the Terms of Service and Privacy Policy
Please subscribe me to the StoodQ newsletters
Guideline to answer a question:

Useful tips to submit your answer
Please read below guidelines before you submit your answer for question.

  • Read and understand question for which you are submitting your answer.
  • Try to avoid grammatical and spell mistake while answering.
  • Do not post any irrelevant information in your answer.
  • Explain your answer with example or any reference link to help who posted question.
  • If you find irrelevant question, please report it to support. Click here to contact support.
  • You agree to the privacy policy and terms of use to submit any contents.

Note: StoodQ is online developers community which helps developer for their difficulty, lets help them with your value contribution.