1
Reply

How to position inner path hexagon center in checkbox?

Neeraj Khajanchi

Neeraj Khajanchi

Jan 4 2018 7:11 AM
132
I have created a ControlTemplate for checkbox using multiple path geometry. The code for the ControlTemplate is as below.
 
I want to position the inner hexagon in center of the outer hexagon, I am not getting how to do that. I tried using Margin but its not working to make it perfect center.
  1. <ControlTemplate x:Key="checkboxTemplateHex" TargetType="CheckBox">  
  2.      <Grid>  
  3.         <Path x:Name="Equis2" Opacity="1" StrokeThickness="1" Stroke="YellowGreen" Fill="Transparent" Data="M7.99999993117449,0.5L15.4999998937224,4.25L15.4999998937224,11.75L7.99999993117449,15.5L0.499999968626539,11.75L0.499999968626537,4.25z"/>  
  4.         <Path x:Name="Equis" Opacity="1" StrokeThickness="0" Stroke="YellowGreen" Fill="YellowGreen" Data="M5.5,0L10.999999995477,2.75L10.999999995477,8.25L5.5,11L4.52300163988895E-09,8.25L4.52300019659901E-09,2.75z"/>  
  5.         <ContentPresenter Margin="0" HorizontalAlignment="Left" VerticalAlignment="Top"/>  
  6.     </Grid>  
  7. </ControlTemplate> 
 Using this ControlTemplate as following
  1. <CheckBox Grid.Row="5" Grid.Column="1" Template="{StaticResource checkboxTemplateHex}" FocusVisualStyle="{x:Null}" IsChecked="True"/> 
 Following is the output
 
 
 

Answers (1)