Skip to content

Instantly share code, notes, and snippets.

@kusa-mochi
Last active August 3, 2018 16:07
Show Gist options
  • Save kusa-mochi/f1fb9b0630d5bd362af89181798a01ad to your computer and use it in GitHub Desktop.
Save kusa-mochi/f1fb9b0630d5bd362af89181798a01ad to your computer and use it in GitHub Desktop.
<ControlTemplate TargetType="{x:Type Button}">
<Grid>
<Grid x:Name="HiddenGrid" Visibility="Hidden">
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<!-- ボタンの高さの1/4の値を取得するためだけに使うGrid -->
<Grid x:Name="CornerRadiusSizeGrid"/>
</Grid>
<!-- 左上と左下の角だけ丸いBorder(の派生クラス)-->
<local:PartialCornerBorder
x:Name="border"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Background="{TemplateBinding Background}"
SnapsToDevicePixels="true"
TopLeftCornerRadius="{Binding ActualHeight, ElementName=CornerRadiusSizeGrid}"
BottomLeftCornerRadius="{Binding ActualHeight, ElementName=CornerRadiusSizeGrid}">
<ContentPresenter x:Name="contentPresenter" Focusable="False" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
</local:PartialCornerBorder>
</Grid>
<ControlTemplate.Triggers>
<!-- 略 -->
</ControlTemplate.Triggers>
</ControlTemplate>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment