wpf Small Round Button

 <Style TargetType="Button" x:Key="SmallRoundButton">
        <Setter Property="Background" Value="Yellow"></Setter>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate>
                    <Grid>
                        <Ellipse x:Name="ell5G" Fill="{Binding Path=Background, RelativeSource={RelativeSource TemplatedParent}}" Stroke="Blue" Height="20" Width="20" HorizontalAlignment="Left"></Ellipse>
                        <TextBlock Text="{Binding Path=Content, RelativeSource={RelativeSource TemplatedParent}}" TextAlignment="Center" VerticalAlignment="Center" HorizontalAlignment="Center"
                                                                   ></TextBlock>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="true">
                            <Setter TargetName="ell5G" Property="Fill" Value="LightBlue"></Setter>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        
    </Style>

猜你喜欢

转载自blog.csdn.net/dxm809/article/details/107518497