Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/77.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 膨胀机的奇怪行为_C#_Html_Wpf_Xaml_User Controls - Fatal编程技术网

C# 膨胀机的奇怪行为

C# 膨胀机的奇怪行为,c#,html,wpf,xaml,user-controls,C#,Html,Wpf,Xaml,User Controls,在我的主页上,我有一个扩展器,它有一个用于动画的事件触发器,如下所示: <StackPanel.Triggers> <EventTrigger RoutedEvent="Expander.Expanded" SourceName="expander"> <EventTrigger.Actions> <BeginS

在我的主页上,我有一个扩展器,它有一个用于动画的事件触发器,如下所示:

            <StackPanel.Triggers>
                <EventTrigger RoutedEvent="Expander.Expanded" SourceName="expander">
                    <EventTrigger.Actions>
                        <BeginStoryboard>
                            <Storyboard>
                                <DoubleAnimation From="0" To="1.2" Duration="0:0:0.35" Storyboard.TargetName="content1" Storyboard.TargetProperty="(FrameworkElement.LayoutTransform).(ScaleTransform.ScaleX)" AutoReverse="False" />
                            </Storyboard>
                        </BeginStoryboard>
                    </EventTrigger.Actions>
                </EventTrigger>
            </StackPanel.Triggers>

            <Expander x:Name="expander" ExpandDirection="Right" OpacityMask="#6C806969" Background="#FF807171" >
            <Grid x:Name="content1" Background="#FF807171" Width="378"> 
                ......user control inside here                      
                    <Grid.LayoutTransform>
                    <ScaleTransform ScaleX="0" ScaleY="1"/>
                </Grid.LayoutTransform>
            </Grid>
        </Expander>

……这里有用户控制
这只是缓慢地将扩展器滑出。但是在一个扩展器头部区域内,我有另一个扩展器(一个垂直设置,另一个水平设置)

水平扩展器是UserControl的一部分。当我展开这个扩展器时,它也会从主窗口触发垂直扩展器

<UserControl x:Class="WpfApplication4.AppPages.AddPost"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" 
             d:DesignHeight="464" d:DesignWidth="416">
    <Expander Header="expander1" Height="441" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top">
    ..... some content
    </Expander> 

……一些内容

有没有办法阻止这种情况发生?

这是我评论中建议的示例代码:

<Expander x:Name="expander" ExpandDirection="Right" OpacityMask="#6C806969" Background="#FF807171">

    ... Content ...

    <Expander.Style>
        <Style TargetType="{x:Type Expander}">
            <Setter Property="LayoutTransform">
                <Setter.Value>
                    <ScaleTransform ScaleX="1" />
                </Setter.Value>
            </Setter>
            <Style.Triggers>
                <Trigger Property="IsExpanded" Value="True">
                    <Trigger.EnterActions>
                        <BeginStoryboard>
                            <Storyboard>
                                <DoubleAnimation From="0" To="1.2" Duration="0:0:0.35" AutoReverse="False"
                                                 Storyboard.TargetProperty="LayoutTransform.(ScaleTransform.ScaleX)" />
                            </Storyboard>
                        </BeginStoryboard>
                    </Trigger.EnterActions>
                </Trigger>       
            </Style.Triggers>
        </Style>
    </Expander.Style>
</Expander>

…内容。。。

尝试为扩展器的
IsExpanded
属性而不是
EventTrigger
使用
Trigger
。我认为
expander.Expanded
路由事件会继续,并且两个扩展器都会捕获它。