Scale checkbox without scaling content

I want to double the size of a checkbox. I used ScaleTransform

, but the problem is that it scales as well Content

(in my case, the text to the right of the checkbox):

<CheckBox VerticalAlignment="Center" Content="Test">
    <CheckBox.LayoutTransform>
        <ScaleTransform ScaleX="2" ScaleY="2" />
    </CheckBox.LayoutTransform>
</CheckBox>

      

enter image description here

I could just leave it Content

blank and write the description in a separate one TextBlock

, but then when I click on the text CheckBox

it certainly doesn't switch.
Can I do this without completely replacing the control template?

+1


source to share


1 answer


Something like this might work for you:

(Obviously, you should use a converter to modify ScaleTransform and TranslateTransform based on data binding for better support).



    <CheckBox VerticalAlignment="Center">
        <CheckBox.Content>
            <TextBlock Text="Test" VerticalAlignment="Center">
                <TextBlock.RenderTransform>
                    <TransformGroup>
                        <TranslateTransform Y="7"/>
                        <ScaleTransform ScaleX="0.5" ScaleY="0.5"/>
                    </TransformGroup>
                </TextBlock.RenderTransform>
            </TextBlock>
        </CheckBox.Content>
        <CheckBox.RenderTransform>
            <ScaleTransform ScaleX="2" ScaleY="2"/>
        </CheckBox.RenderTransform>
    </CheckBox>

      

+3


source







All Articles