CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2018
    Posts
    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

  2. #2
    Join Date
    May 2019
    Location
    601 & 612, The Times square Arcade, Near Baghban party plot, Thaltej - Shilaj Rd, Thaltej, Ahmedabad, Gujarat 380059, India
    Posts
    7

    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
  •  





Click Here to Expand Forum to Full Width

Featured