dimanche 28 juin 2015

Custom button style alignment wpf

I tried modifying a button style in order to remove the Chrome System-like button. Everything works out fine there but the content of the button will not align properly at the center of the button.

Button Style:

<Style x:Key="NoChrome" TargetType="{x:Type Button}">
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="Button">
                    <ContentPresenter/>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

Button declaration:

<Button Content="Button" Canvas.Left="141" Canvas.Top="324" Width="75" Style="{DynamicResource NoChrome}"/>

Aucun commentaire:

Enregistrer un commentaire