当前位置: 首页 > 工具软件 > path button > 使用案例 >

WPF--->自定义Button圆形按钮Stylet

缪朝
2023-12-01
	<Style x:Key="CircularButton" TargetType="Button">
		<Setter Property="Height" Value="20"/>
		<Setter Property="Width" Value="20"/>
		<Setter Property="Background" Value="#ffffff"/>
		<Setter Property="BorderBrush" Value="#b4b4b4"/>
		<Setter Property="BorderThickness" Value="1"/>
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="Button">
						<Grid>
							<Ellipse x:Name="ellipse" Width="{TemplateBinding Width}" Height="{TemplateBinding Height}"
								 Stroke="{TemplateBinding BorderBrush}" StrokeThickness="{TemplateBinding BorderThickness}" 
								 Fill="{TemplateBinding Background}"
								 VerticalAlignment="Center"  HorizontalAlignment="Center" IsHitTestVisible="True">
							</Ellipse>
						<Path Name="PART_ButtonPath" IsHitTestVisible="True" Fill="{TemplateBinding BorderBrush}" Data="M512 801.6896L5.12 282.0096l58.1632-59.5968L512 682.3936l448.7168-460.0832 58.1632 59.5968-506.88 519.7824z" Width="10" Height="10" VerticalAlignment="Center" HorizontalAlignment="Center" Stretch="Uniform"/>
						</Grid>
					<ControlTemplate.Triggers>
						<Trigger Property="IsMouseOver" Value="True">
							<Setter Property="BorderBrush" Value="#2561a9"/>
							<Setter Property="Background" Value="#ccdfeb"/>
						</Trigger>
					</ControlTemplate.Triggers>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
	</Style>
 类似资料: