我有一个按钮的 XAML 代码。我需要这个按钮只是一个纯色的圆圈。
<Button x:Name="btn_Color" Grid.Column="0" Grid.Row="2" HorizontalAlignment="Center" VerticalAlignment="Center" Height="25" Width="25" BorderBrush="Black">
<Button.Template>
<ControlTemplate TargetType="Button">
<Grid>
<Ellipse Fill="Black"/>
</Grid>
</ControlTemplate>
</Button.Template>
</Button>
我希望这个按钮在我点击时改变颜色,并且能够将此代码重用于其他按钮。我稍后会将颜色用于其他用途,因此我需要能够访问该数据。我尝试将 PreviewMouseDown 事件添加到 Ellipse 并更改该属性,(Ellipse)sender但即使我将其添加为一个x:Name属性,我也无法访问 Ellipse 的颜色。我怎样才能做到这一点?谢谢!:)
相关分类