gpt4 book ai didi

wpf - WPF-在IsMouseOver上使用ToggleButton触发器时,程序失败

转载 作者:行者123 更新时间:2023-12-03 17:24:17 25 4
gpt4 key购买 nike

每当我尝试使用ToggleButton上的触发器更改路径填充时,都会遇到奇怪的崩溃。经过一些消除过程后,似乎实际的触发器属性正在导致程序崩溃。

当它崩溃时,我得到这个:

Problem signature:

Problem Event Name: CLR20r3
Problem Signature 01: briantestwpf.exe
Problem Signature 02: 1.0.0.0
Problem Signature 03: 54de1f87
Problem Signature 04: PresentationFramework
Problem Signature 05: 4.0.30319.18408
Problem Signature 06: 52312f13
Problem Signature 07: 65f2
Problem Signature 08: 5e
Problem Signature 09: System.Windows.Markup.XamlParse
OS Version: 6.1.7601.2.1.0.256.4
Locale ID: 1033
Additional Information 1: 0a9e
Additional Information 2: 0a9e372d3b4ad19135b953a78882e789
Additional Information 3: 0a9e
Additional Information 4: 0a9e372d3b4ad19135b953a78882e789



这是有问题的代码,没有花哨,因为我试图弄乱这个概念。我的项目负责人对此也感到困惑。
<ToggleButton Background="Transparent" BorderThickness="1" BorderBrush="Transparent" Canvas.Left="410" Canvas.Top="384" Height="41" Width="81">
<Canvas>

<Path x:Name="Arrow"
Width="32"
Data="M0,0 L0,2 L4,6 L8,2 L0,2 "
Fill="#FF827F96" Canvas.Left="0" Canvas.Top="-15" Stretch="Fill" Height="29" />
</Canvas>
<ToggleButton.Triggers>
<Trigger Property="UIElement.IsMouseOver" Value="True">
<Setter TargetName="Arrow" Property="Path.Fill" Value="GhostWhite"/>
</Trigger>
</ToggleButton.Triggers>
</ToggleButton>

非常感谢你!

最佳答案

尝试这个 -

<ToggleButton Background="Transparent" BorderThickness="1" BorderBrush="Transparent" Canvas.Left="410" Canvas.Top="384" Height="41" Width="81">
<Canvas>
<Path x:Name="Arrow" Width="32" Data="M0,0 L0,2 L4,6 L8,2 L0,2 " Fill="#FF827F96" Canvas.Left="0" Canvas.Top="-15" Stretch="Fill" Height="29" >
<Path.Style>
<Style TargetType="Path">
<Style.Triggers>
<DataTrigger Binding="{Binding Path=IsMouseOver, RelativeSource={RelativeSource AncestorType={x:Type ToggleButton}}}" Value="True">
<Setter Property="Stroke" Value="GhostWhite"/>
</DataTrigger>
</Style.Triggers>
</Style>
</Path.Style>
</Path>
</Canvas>
</ToggleButton>

关于wpf - WPF-在IsMouseOver上使用ToggleButton触发器时,程序失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28503774/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com