我是C#和XAML的新手,但有网络设计语言的经验。目前我正在开展我的第一个项目,但我遇到了问题..
在xaml中,我创建了我的按钮:
<Button Margin="10 0 0 0" Click="CloseClick">
<Button.Template>
<ControlTemplate>
<Border Background="{x:Null}" IsHitTestVisible="True">
<Canvas Width="15" Height="15">
<Ellipse HorizontalAlignment="Left" Height="15" Grid.Row="0" Width="15">
<Ellipse.Fill>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#FF8C8E8D" Offset="0"/>
<GradientStop Color="#FF54545C" Offset="0.987"/>
</LinearGradientBrush>
</Ellipse.Fill>
</Ellipse>
<Path Data="F1M54.0573,47.8776L38.1771,31.9974 54.0547,16.1198C55.7604,14.4141 55.7604,11.6511 54.0573,9.94531 52.3516,8.23962 49.5859,8.23962 47.8802,9.94531L32.0026,25.8229 16.1224,9.94531C14.4167,8.23962 11.6511,8.23962 9.94794,9.94531 8.24219,11.6511 8.24219,14.4141 9.94794,16.1198L25.8255,32 9.94794,47.8776C8.24219,49.5834 8.24219,52.3477 9.94794,54.0534 11.6511,55.7572 14.4167,55.7585 16.1224,54.0534L32.0026,38.1745 47.8802,54.0534C49.5859,55.7585 52.3516,55.7572 54.0573,54.0534 55.7604,52.3477 55.763,49.5834 54.0573,47.8776z" Stretch="Uniform" Fill="#FF3D3E50" Width="8" Height="8" Canvas.Top="3.5" Canvas.Left="3.5"/>
</Canvas>
</Border>
</ControlTemplate>
</Button.Template>
</Button>
现在在悬停事件中,我想让其他按钮看起来像中间的按钮!
我尝试过:
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="ellipse1" Property="Fill" Value="Orange"/>
</Trigger>
</Style.Triggers>
我还尝试了更多Code,但我不再拥有它,因为它不起作用..
我将非常感谢您的帮助!
答案 0 :(得分:1)
您的代码遗失 id loc1 loc2 loc3
aaa US UK None
abb FR US IN
acd US CN CN
:如下所示更正,因此x:Name="ellipse1"
将起作用(即在Trigger
事件中将Fill
颜色更改为橙色):< / p>
MouseOver