请问关于c的具体应用场景有哪些?
- 内容介绍
- 文章标签
- 相关推荐
本文共计288个文字,预计阅读时间需要2分钟。
我有这样一个Viewbox:Viewbox: x:Key=SampleViewbox Grid.Ellipse Stroke=
我有一个Viewbox:<Viewbox x:Key="SampleViewbox" > <Grid> <Ellipse Stroke="#e2e2e0" StrokeThickness="6" Fill="#d5273e" Width="128" Height="128"/> </Grid> </Viewbox>
然后我将其包含在样式中:
<Style x:Key="SampleStyle" TargetType="{x:Type Button}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type Button}"> <Border Background="Transparent" > <ContentPresenter Content="{StaticResource SampleViewbox}"/> </Border> </ControlTemplate> </Setter.Value> </Setter> </Style>
现在我使用SampleStyle创建了许多按钮
<Grid> <StackPanel> <Button Style="{StaticResource SampleStyle}" Height="50" Width="50"></Button> <Button Style="{StaticResource SampleStyle}" Height="80" Width="80"></Button> <Button Style="{StaticResource SampleStyle}" Height="20" Width="20"></Button> </StackPanel> </Grid>
但是,只有一个按钮具有椭圆(视图框)
如何让所有按钮都显示/显示椭圆?
Viewbox是FrameworkElement,不能属于多个父项.每次按钮请求资源{StaticResource SampleViewbox}时,它们都会获得相同的实例.要更改该行为,请添加x:Shared =“False”属性
<Viewbox x:Key="SampleViewbox" x:Shared="False">
本文共计288个文字,预计阅读时间需要2分钟。
我有这样一个Viewbox:Viewbox: x:Key=SampleViewbox Grid.Ellipse Stroke=
我有一个Viewbox:<Viewbox x:Key="SampleViewbox" > <Grid> <Ellipse Stroke="#e2e2e0" StrokeThickness="6" Fill="#d5273e" Width="128" Height="128"/> </Grid> </Viewbox>
然后我将其包含在样式中:
<Style x:Key="SampleStyle" TargetType="{x:Type Button}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type Button}"> <Border Background="Transparent" > <ContentPresenter Content="{StaticResource SampleViewbox}"/> </Border> </ControlTemplate> </Setter.Value> </Setter> </Style>
现在我使用SampleStyle创建了许多按钮
<Grid> <StackPanel> <Button Style="{StaticResource SampleStyle}" Height="50" Width="50"></Button> <Button Style="{StaticResource SampleStyle}" Height="80" Width="80"></Button> <Button Style="{StaticResource SampleStyle}" Height="20" Width="20"></Button> </StackPanel> </Grid>
但是,只有一个按钮具有椭圆(视图框)
如何让所有按钮都显示/显示椭圆?
Viewbox是FrameworkElement,不能属于多个父项.每次按钮请求资源{StaticResource SampleViewbox}时,它们都会获得相同的实例.要更改该行为,请添加x:Shared =“False”属性
<Viewbox x:Key="SampleViewbox" x:Shared="False">

