扩展器控件出现问题 [英] Problem with the Expander control

查看:51
本文介绍了扩展器控件出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

XAML

XAML

<UserControl x:Class="Iformata.Vnoc.UI.AirlineScheduler.SpaceStatusFilter"

    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

    xmlns:controls="clr-namespace:Microsoft.Windows.Controls;assembly=Microsoft.Windows.Controls"

   >
    <UserControl.Resources>
        <Style x:Key="StatusExpanderStyle" TargetType="controls:Expander">
            <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
            <Setter Property="VerticalContentAlignment" Value="Stretch"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="controls:Expander">
                        <Grid Background="Transparent">
                            <Grid.Resources>
                                <LinearGradientBrush x:Key="ExpanderArrowFill" EndPoint="0,1" StartPoint="0,0">
                                    <GradientStop Color="White" Offset="0"/>
                                    <GradientStop Color="#FFBFBFBF" Offset="0.5"/>
                                    <GradientStop Color="#FF878787" Offset="1"/>
                                </LinearGradientBrush>
                                <LinearGradientBrush x:Key="ExpanderArrowHoverFill" EndPoint="0,1" StartPoint="0,0">
                                    <GradientStop Color="#FFF0F8FE" Offset="0"/>
                                    <GradientStop Color="#FFE0F3FE" Offset="0.3"/>
                                    <GradientStop Color="#FF6FA7C5" Offset="1"/>
                                </LinearGradientBrush>
                                <LinearGradientBrush x:Key="ExpanderArrowPressedFill" EndPoint="0,1" StartPoint="0,0">
                                    <GradientStop Color="#FFDCF0FA" Offset="0"/>
                                    <GradientStop Color="#FFC5E6F7" Offset="0.2"/>
                                    <GradientStop Color="#FF5690D0" Offset="1"/>
                                </LinearGradientBrush>
                                <ControlTemplate x:Key="ExpanderDownHeaderTemplate" TargetType="ToggleButton">
                                    <Grid Background="Transparent">
                                        <VisualStateManager.VisualStateGroups>
                                            <VisualStateGroup x:Name="CheckStates">
                                                <VisualStateGroup.Transitions>
                                                    <VisualTransition GeneratedDuration="00:00:00"/>
                                                </VisualStateGroup.Transitions>
                                                <VisualState x:Name="Checked">
                                                    <Storyboard>
                                                        <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="arrow" Storyboard.TargetProperty="Data">
                                                            <DiscreteObjectKeyFrame KeyTime="0" Value="M 1,4.5 L 4.5,1 L 8,4.5"/>
                                                        </ObjectAnimationUsingKeyFrames>
                                                    </Storyboard>
                                                </VisualState>
                                                <VisualState x:Name="Unchecked"/>
                                             </VisualStateGroup>
                                            <VisualStateGroup x:Name="CommonStates">
                                                <VisualStateGroup.Transitions>
                                                    <VisualTransition GeneratedDuration="0"/>
                                                    <VisualTransition GeneratedDuration="00:00:00.1" To="MouseOver"/>
                                                    <VisualTransition GeneratedDuration="00:00:00.1" To="Pressed"/>
                                                </VisualStateGroup.Transitions>
                                                <VisualState x:Name="Normal"/>
                                                <VisualState x:Name="MouseOver">
                                                </VisualState>
                                                <VisualState x:Name="Pressed">
                                                    <Storyboard>
                                                        <ColorAnimation BeginTime="0" Storyboard.TargetName="circle" Storyboard.TargetProperty="(Ellipse.Stroke).(SolidColorBrush.Color)" To="#FF526C7B"/>
                                                        <DoubleAnimation BeginTime="0" Storyboard.TargetName="circle" Storyboard.TargetProperty="StrokeThickness" To="1.5"/>
                                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="circle" Storyboard.TargetProperty="(Ellipse.Fill)">
                                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource ExpanderArrowPressedFill}"/>
                                                        </ObjectAnimationUsingKeyFrames>
                                                        <ColorAnimation BeginTime="0" Storyboard.TargetName="arrow" Storyboard.TargetProperty="(Path.Stroke).(SolidColorBrush.Color)" To="#FF003366"/>
                                                    </Storyboard>
                                                </VisualState>
                                            </VisualStateGroup>
                                            <VisualStateGroup x:Name="FocusStates">
                                                <VisualState x:Name="Focused">
                                                    <Storyboard>
                                                        <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="FocusVisualElement" Storyboard.TargetProperty="Visibility">
                                                            <DiscreteObjectKeyFrame KeyTime="0" Value="Visible"/>
                                                        </ObjectAnimationUsingKeyFrames>
                                                    </Storyboard>
                                                </VisualState>
                                                <VisualState x:Name="Unfocused"/>
                                            </VisualStateGroup>
                                        </VisualStateManager.VisualStateGroups>
                                        <Border Padding="{TemplateBinding Padding}">
                                            <Grid Background="Transparent">
                                                <Grid.ColumnDefinitions>
                                                    <ColumnDefinition Width="*"/>
                                                    <ColumnDefinition Width="19"/>
                                                </Grid.ColumnDefinitions>
                                                <Grid HorizontalAlignment="Center" VerticalAlignment="Center" Grid.Column="1">
                                                    <Ellipse Height="19" HorizontalAlignment="Center" x:Name="circle" VerticalAlignment="Center" Width="19" Fill="{StaticResource ExpanderArrowFill}" Stroke="DarkGray" Visibility="Collapsed"/>
                                                    <Path HorizontalAlignment="Center" x:Name="arrow" VerticalAlignment="Center" Stroke="White" StrokeThickness="2" Data="M 1,1.5 L 4.5,5 L 8,1.5"/>
                                                </Grid>
                                                <ContentPresenter HorizontalAlignment="Left" Margin="5,0,0,0" x:Name="header" VerticalAlignment="Center" Grid.Column="0" Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}"/>
                                            </Grid>
                                        </Border>
                                        <Border x:Name="FocusVisualElement" IsHitTestVisible="false" Visibility="Collapsed"/>
                                    </Grid>
                                </ControlTemplate>
                                <ControlTemplate x:Key="ExpanderUpHeaderTemplate" TargetType="ToggleButton">
                                    <Grid Background="Transparent">
                                        <VisualStateManager.VisualStateGroups>
                                            <VisualStateGroup x:Name="CheckStates">
                                                <VisualStateGroup.Transitions>
                                                    <VisualTransition GeneratedDuration="00:00:00"/>
                                                </VisualStateGroup.Transitions>
                                                <VisualState x:Name="Checked">
                                                    <Storyboard>
                                                        <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="arrow" Storyboard.TargetProperty="Data">
                                                            <DiscreteObjectKeyFrame KeyTime="0" Value="M 1,4.5 L 4.5,1 L 8,4.5"/>
                                                        </ObjectAnimationUsingKeyFrames>
                                                    </Storyboard>
                                                </VisualState>
                                                <VisualState x:Name="Unchecked"/>
                                             </VisualStateGroup>
                                            <VisualStateGroup x:Name="CommonStates">
                                                <VisualStateGroup.Transitions>
                                                    <VisualTransition GeneratedDuration="0"/>
                                                    <VisualTransition GeneratedDuration="00:00:00.1" To="MouseOver"/>
                                                    <VisualTransition GeneratedDuration="00:00:00.1" To="Pressed"/>
                                                </VisualStateGroup.Transitions>
                                                <VisualState x:Name="Normal"/>
                                                <VisualState x:Name="MouseOver">

                                                </VisualState>
                                                <VisualState x:Name="Pressed">
                                                    <Storyboard>
                                                        <ColorAnimation BeginTime="0" Storyboard.TargetName="circle" Storyboard.TargetProperty="(Ellipse.Stroke).(SolidColorBrush.Color)" To="#FF526C7B"/>
                                                        <DoubleAnimation BeginTime="0" Storyboard.TargetName="circle" Storyboard.TargetProperty="StrokeThickness" To="1.5"/>
                                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="circle" Storyboard.TargetProperty="(Ellipse.Fill)">
                                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource ExpanderArrowPressedFill}"/>
                                                        </ObjectAnimationUsingKeyFrames>
                                                        <ColorAnimation BeginTime="0" Storyboard.TargetName="arrow" Storyboard.TargetProperty="(Path.Stroke).(SolidColorBrush.Color)" To="#FF003366"/>
                                                    </Storyboard>
                                                </VisualState>
                                            </VisualStateGroup>
                                            <VisualStateGroup x:Name="FocusStates">
                                                <VisualState x:Name="Focused">
                                                    <Storyboard>
                                                        <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="FocusVisualElement" Storyboard.TargetProperty="Visibility">
                                                            <DiscreteObjectKeyFrame KeyTime="0" Value="Visible"/>
                                                        </ObjectAnimationUsingKeyFrames>
                                                    </Storyboard>
                                                </VisualState>
                                                <VisualState x:Name="Unfocused"/>
                                            </VisualStateGroup>
                                        </VisualStateManager.VisualStateGroups>
                                        <Border Padding="{TemplateBinding Padding}">
                                            <Grid Background="Transparent">
                                                <Grid.ColumnDefinitions>
                                                    <ColumnDefinition Width="19"/>
                                                    <ColumnDefinition Width="*"/>
                                                </Grid.ColumnDefinitions>
                                                <Grid HorizontalAlignment="Left" VerticalAlignment="Top">
                                                    <Grid.RenderTransform>
                                                        <TransformGroup>
                                                            <TransformGroup.Children>
                                                                <TransformCollection>
                                                                    <RotateTransform Angle="180" CenterX="9.5" CenterY="9.5"/>
                                                                </TransformCollection>
                                                            </TransformGroup.Children>
                                                        </TransformGroup>
                                                    </Grid.RenderTransform>
                                                    <Ellipse Height="19" HorizontalAlignment="Center" x:Name="circle" VerticalAlignment="Center" Width="19" Fill="{StaticResource ExpanderArrowFill}" Stroke="DarkGray"/>
                                                    <Path HorizontalAlignment="Center" x:Name="arrow" VerticalAlignment="Center" Stroke="#666" StrokeThickness="2" Data="M 1,1.5 L 4.5,5 L 8,1.5"/>
                                                </Grid>
                                                <ContentPresenter HorizontalAlignment="Left" Margin="4,0,0,0" x:Name="header" VerticalAlignment="Center" Grid.Column="1" Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}"/>
                                            </Grid>
                                        </Border>
                                        <Border x:Name="FocusVisualElement" IsHitTestVisible="false" Visibility="Collapsed" BorderThickness="1" CornerRadius="3">
                                            <Border.BorderBrush>
                                                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                                    <GradientStop Color="#FFA3AEB9"/>
                                                    <GradientStop Color="#FF8399A9" Offset="0.375"/>
                                                    <GradientStop Color="#FF718597" Offset="0.375"/>
                                                    <GradientStop Color="#FF617584" Offset="1"/>
                                                </LinearGradientBrush>
                                            </Border.BorderBrush>
                                        </Border>
                                    </Grid>
                                </ControlTemplate>
                                <ControlTemplate x:Key="ExpanderLeftHeaderTemplate" TargetType="ToggleButton">
                                    <Grid Background="Transparent">
                                        <VisualStateManager.VisualStateGroups>
                                            <VisualStateGroup x:Name="CheckStates">
                                                <VisualStateGroup.Transitions>
                                                    <VisualTransition GeneratedDuration="00:00:00"/>
                                                </VisualStateGroup.Transitions>
                                                <VisualState x:Name="Checked">
                                                    <Storyboard>
                                                        <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="arrow" Storyboard.TargetProperty="Data">
                                                            <DiscreteObjectKeyFrame KeyTime="0" Value="M 1,4.5 L 4.5,1 L 8,4.5"/>
                                                        </ObjectAnimationUsingKeyFrames>
                                                    </Storyboard>
                                                </VisualState>
                                                <VisualState x:Name="Unchecked"/>
                                                  </VisualStateGroup>
                                            <VisualStateGroup x:Name="CommonStates">
                                                <VisualStateGroup.Transitions>
                                                    <VisualTransition GeneratedDuration="0"/>
                                                    <VisualTransition GeneratedDuration="00:00:00.1" To="MouseOver"/>
                                                    <VisualTransition GeneratedDuration="00:00:00.1" To="Pressed"/>
                                                </VisualStateGroup.Transitions>
                                                <VisualState x:Name="Normal"/>
                                                <VisualState x:Name="MouseOver">
                                                    <Storyboard>
                                                        <ColorAnimation BeginTime="0" Storyboard.TargetName="circle" Storyboard.TargetProperty="(Ellipse.Stroke).(SolidColorBrush.Color)" To="#FF3C7FB1"/>
                                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="circle" Storyboard.TargetProperty="(Ellipse.Fill)">
                                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource ExpanderArrowHoverFill}"/>
                                                        </ObjectAnimationUsingKeyFrames>
                                                        <ColorAnimation BeginTime="0" Storyboard.TargetName="arrow" Storyboard.TargetProperty="(Path.Stroke).(SolidColorBrush.Color)" To="#222"/>
                                                    </Storyboard>
                                                </VisualState>
                                                <VisualState x:Name="Pressed">
                                                    <Storyboard>
                                                        <ColorAnimation BeginTime="0" Storyboard.TargetName="circle" Storyboard.TargetProperty="(Ellipse.Stroke).(SolidColorBrush.Color)" To="#FF526C7B"/>
                                                        <DoubleAnimation BeginTime="0" Storyboard.TargetName="circle" Storyboard.TargetProperty="StrokeThickness" To="1.5"/>
                                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="circle" Storyboard.TargetProperty="(Ellipse.Fill)">
                                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource ExpanderArrowPressedFill}"/>
                                                        </ObjectAnimationUsingKeyFrames>
                                                        <ColorAnimation BeginTime="0" Storyboard.TargetName="arrow" Storyboard.TargetProperty="(Path.Stroke).(SolidColorBrush.Color)" To="#FF003366"/>
                                                    </Storyboard>
                                                </VisualState>
                                            </VisualStateGroup>
                                            <VisualStateGroup x:Name="FocusStates">
                                                <VisualState x:Name="Focused">
                                                    <Storyboard>
                                                        <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="FocusVisualElement" Storyboard.TargetProperty="Visibility">
                                                            <DiscreteObjectKeyFrame KeyTime="0" Value="Visible"/>
                                                        </ObjectAnimationUsingKeyFrames>
                                                    </Storyboard>
                                                </VisualState>
                                                <VisualState x:Name="Unfocused"/>
                                            </VisualStateGroup>
                                        </VisualStateManager.VisualStateGroups>
                                        <Border Padding="{TemplateBinding Padding}">
                                            <Grid Background="Transparent">
                                                <Grid.RowDefinitions>
                                                    <RowDefinition Height="19"/>
                                                    <RowDefinition Height="*"/>
                                                </Grid.RowDefinitions>
                                                <Grid HorizontalAlignment="Center" VerticalAlignment="Top">
                                                    <Grid.RenderTransform>
                                                        <TransformGroup>
                                                            <TransformGroup.Children>
                                                                <TransformCollection>
                                                                    <RotateTransform Angle="90" CenterX="9.5" CenterY="9.5"/>
                                                                </TransformCollection>
                                                            </TransformGroup.Children>
                                                        </TransformGroup>
                                                    </Grid.RenderTransform>
                                                    <Ellipse Height="19" HorizontalAlignment="Center" x:Name="circle" VerticalAlignment="Center" Width="19" Fill="{StaticResource ExpanderArrowFill}" Stroke="DarkGray"/>
                                                    <Path HorizontalAlignment="Center" x:Name="arrow" VerticalAlignment="Center" Stroke="#666" StrokeThickness="2" Data="M 1,1.5 L 4.5,5 L 8,1.5"/>
                                                </Grid>
                                                <ContentPresenter HorizontalAlignment="Center" Margin="0,4,0,0" x:Name="header" VerticalAlignment="Top" Grid.Row="1" Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}"/>
                                            </Grid>
                                        </Border>
                                        <Border x:Name="FocusVisualElement" IsHitTestVisible="false" Visibility="Collapsed" BorderThickness="1" CornerRadius="3">
                                            <Border.BorderBrush>
                                                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                                    <GradientStop Color="#FFA3AEB9"/>
                                                    <GradientStop Color="#FF8399A9" Offset="0.375"/>
                                                    <GradientStop Color="#FF718597" Offset="0.375"/>
                                                    <GradientStop Color="#FF617584" Offset="1"/>
                                                </LinearGradientBrush>
                                            </Border.BorderBrush>
                                        </Border>
                                    </Grid>
                                </ControlTemplate>
                                <ControlTemplate x:Key="ExpanderRightHeaderTemplate" TargetType="ToggleButton">
                                    <Grid Background="Transparent">
                                        <VisualStateManager.VisualStateGroups>
                                            <VisualStateGroup x:Name="CheckStates">
                                                <VisualStateGroup.Transitions>
                                                    <VisualTransition GeneratedDuration="00:00:00"/>
                                                </VisualStateGroup.Transitions>
                                                <VisualState x:Name="Checked">
                                                    <Storyboard>
                                                        <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="arrow" Storyboard.TargetProperty="Data">
                                                            <DiscreteObjectKeyFrame KeyTime="0" Value="M 1,4.5 L 4.5,1 L 8,4.5"/>
                                                        </ObjectAnimationUsingKeyFrames>
                                                    </Storyboard>
                                                </VisualState>
                                                <VisualState x:Name="Unchecked"/>
                                                  </VisualStateGroup>
                                            <VisualStateGroup x:Name="CommonStates">
                                                <VisualStateGroup.Transitions>
                                                    <VisualTransition GeneratedDuration="0"/>
                                                    <VisualTransition GeneratedDuration="00:00:00.1" To="MouseOver"/>
                                                    <VisualTransition GeneratedDuration="00:00:00.1" To="Pressed"/>
                                                </VisualStateGroup.Transitions>
                                                <VisualState x:Name="Normal"/>
                                                <VisualState x:Name="MouseOver">
                                                    <Storyboard>
                                                        <ColorAnimation BeginTime="0" Storyboard.TargetName="circle" Storyboard.TargetProperty="(Ellipse.Stroke).(SolidColorBrush.Color)" To="#FF3C7FB1"/>
                                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="circle" Storyboard.TargetProperty="(Ellipse.Fill)">
                                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource ExpanderArrowHoverFill}"/>
                                                        </ObjectAnimationUsingKeyFrames>
                                                        <ColorAnimation BeginTime="0" Storyboard.TargetName="arrow" Storyboard.TargetProperty="(Path.Stroke).(SolidColorBrush.Color)" To="#222"/>
                                                    </Storyboard>
                                                </VisualState>
                                                <VisualState x:Name="Pressed">
                                                    <Storyboard>
                                                        <ColorAnimation BeginTime="0" Storyboard.TargetName="circle" Storyboard.TargetProperty="(Ellipse.Stroke).(SolidColorBrush.Color)" To="#FF526C7B"/>
                                                        <DoubleAnimation BeginTime="0" Storyboard.TargetName="circle" Storyboard.TargetProperty="StrokeThickness" To="1.5"/>
                                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="circle" Storyboard.TargetProperty="(Ellipse.Fill)">
                                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource ExpanderArrowPressedFill}"/>
                                                        </ObjectAnimationUsingKeyFrames>
                                                        <ColorAnimation BeginTime="0" Storyboard.TargetName="arrow" Storyboard.TargetProperty="(Path.Stroke).(SolidColorBrush.Color)" To="#FF003366"/>
                                                    </Storyboard>
                                                </VisualState>
                                            </VisualStateGroup>
                                            <VisualStateGroup x:Name="FocusStates">
                                                <VisualState x:Name="Focused">
                                                    <Storyboard>
                                                        <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="FocusVisualElement" Storyboard.TargetProperty="Visibility">
                                                            <DiscreteObjectKeyFrame KeyTime="0" Value="Visible"/>
                                                        </ObjectAnimationUsingKeyFrames>
                                                    </Storyboard>
                                                </VisualState>
                                                <VisualState x:Name="Unfocused"/>
                                            </VisualStateGroup>
                                        </VisualStateManager.VisualStateGroups>
                                        <Border Padding="{TemplateBinding Padding}">
                                            <Grid Background="Transparent">
                                                <Grid.RowDefinitions>
                                                    <RowDefinition Height="19"/>
                                                    <RowDefinition Height="*"/>
                                                </Grid.RowDefinitions>
                                                <Grid HorizontalAlignment="Center" VerticalAlignment="Top">
                                                    <Grid.RenderTransform>
                                                        <TransformGroup>
                                                            <TransformGroup.Children>
                                                                <TransformCollection>
                                                                    <RotateTransform Angle="-90" CenterX="9.5" CenterY="9.5"/>
                                                                </TransformCollection>
                                                            </TransformGroup.Children>
                                                        </TransformGroup>
                                                    </Grid.RenderTransform>
                                                    <Ellipse Height="19" HorizontalAlignment="Center" x:Name="circle" VerticalAlignment="Center" Width="19" Fill="{StaticResource ExpanderArrowFill}" Stroke="DarkGray"/>
                                                    <Path HorizontalAlignment="Center" x:Name="arrow" VerticalAlignment="Center" Stroke="#666" StrokeThickness="2" Data="M 1,1.5 L 4.5,5 L 8,1.5"/>
                                                </Grid>
                                                <ContentPresenter HorizontalAlignment="Center" Margin="0,4,0,0" x:Name="header" VerticalAlignment="Top" Grid.Row="1" Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}"/>
                                            </Grid>
                                        </Border>
                                        <Border x:Name="FocusVisualElement" IsHitTestVisible="false" Visibility="Collapsed" BorderThickness="1" CornerRadius="3">
                                            <Border.BorderBrush>
                                                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                                    <GradientStop Color="#FFA3AEB9"/>
                                                    <GradientStop Color="#FF8399A9" Offset="0.375"/>
                                                    <GradientStop Color="#FF718597" Offset="0.375"/>
                                                    <GradientStop Color="#FF617584" Offset="1"/>
                                                </LinearGradientBrush>
                                            </Border.BorderBrush>
                                        </Border>
                                    </Grid>
                                </ControlTemplate>
                            </Grid.Resources>
                            <VisualStateManager.VisualStateGroups>
                                <VisualStateGroup x:Name="CommonStates">
                                    <VisualStateGroup.Transitions>
                                        <VisualTransition GeneratedDuration="0"/>
                                    </VisualStateGroup.Transitions>
                                    <VisualState x:Name="Normal"/>
                                    <VisualState x:Name="Disabled">
                                        <Storyboard>
                                            <DoubleAnimation Duration="0" Storyboard.TargetName="DisabledVisualElement" Storyboard.TargetProperty="(UIElement.Opacity)" To="1"/>
                                        </Storyboard>
                                    </VisualState>
                                </VisualStateGroup>
                                <VisualStateGroup x:Name="FocusStates">
                                    <VisualState x:Name="Focused">
                                        <Storyboard>
                                            <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="FocusVisualElement" Storyboard.TargetProperty="Visibility">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="Visible"/>
                                            </ObjectAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="Unfocused"/>
                                </VisualStateGroup>
                                <VisualStateGroup x:Name="ExpansionStates">
                                    <VisualStateGroup.Transitions>
                                        <VisualTransition GeneratedDuration="0"/>
                                    </VisualStateGroup.Transitions>
                                    <VisualState x:Name="Collapsed"/>
                                    <VisualState x:Name="Expanded">
                                        <Storyboard>
                                            <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="ExpandSite" Storyboard.TargetProperty="Visibility">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="Visible"/>
                                            </ObjectAnimationUsingKeyFrames>
                                            <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="ExpandSite" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)">
                                                <SplineDoubleKeyFrame KeyTime="00:00:00" Value="-35"/>
                                                <SplineDoubleKeyFrame KeyTime="00:00:00.3000000" Value="0"/>
                                                <SplineDoubleKeyFrame KeyTime="00:00:00.4000000" Value="-4"/>
                                                <SplineDoubleKeyFrame KeyTime="00:00:00.5000000" Value="0"/>
                                            </DoubleAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualState>
                                </VisualStateGroup>
                                <VisualStateGroup x:Name="ExpandDirectionStates">
                                    <VisualStateGroup.Transitions>
                                        <VisualTransition GeneratedDuration="0"/>
                                    </VisualStateGroup.Transitions>
                                    <VisualState x:Name="ExpandDown">
                                        <Storyboard>
                                            <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="rd1" Storyboard.TargetProperty="Height">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="*"/>
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="cd0" Storyboard.TargetProperty="Width">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="*"/>
                                            </ObjectAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="ExpandUp">
                                        <Storyboard>
                                            <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="ExpanderButton" Storyboard.TargetProperty="Template">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource ExpanderUpHeaderTemplate}"/>
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="ExpanderButton" Storyboard.TargetProperty="(Grid.Row)">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="1"/>
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="ExpandSite" Storyboard.TargetProperty="(Grid.Row)">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="0"/>
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="rd0" Storyboard.TargetProperty="Height">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="*"/>
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="cd0" Storyboard.TargetProperty="Width">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="*"/>
                                            </ObjectAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="ExpandLeft">

                                        <Storyboard>
                                            <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="cd1" Storyboard.TargetProperty="Width">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="*"/>
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="rd0" Storyboard.TargetProperty="Height">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="*"/>
                                            </ObjectAnimationUsingKeyFrames>
                                        </Storyboard>

                                    </VisualState>
                                    <VisualState x:Name="ExpandRight">
                                        <Storyboard>
                                            <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="ExpanderButton" Storyboard.TargetProperty="Template">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource ExpanderRightHeaderTemplate}"/>
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="ExpandSite" Storyboard.TargetProperty="(Grid.Row)">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="0"/>
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames Duration="1" Storyboard.TargetName="ExpandSite" Storyboard.TargetProperty="(Grid.Column)">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="1"/>
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="rd0" Storyboard.TargetProperty="Height">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="*"/>
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="cd1" Storyboard.TargetProperty="Width">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="*"/>
                                            </ObjectAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualState>
                                </VisualStateGroup>
                            </VisualStateManager.VisualStateGroups>
                            <Border x:Name="Background" Background="{TemplateBinding Background}" Padding="{TemplateBinding Padding}">
                                <Grid>
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="Auto" x:Name="rd0"/>
                                        <RowDefinition Height="Auto" x:Name="rd1"/>
                                    </Grid.RowDefinitions>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="Auto" x:Name="cd0"/>
                                        <ColumnDefinition Width="Auto" x:Name="cd1"/>
                                    </Grid.ColumnDefinitions>
                                    <Border x:Name="border" Cursor="Hand" Grid.ColumnSpan="2" Grid.RowSpan="1" Padding="0,0,0,0" Canvas.ZIndex="1">
                                        <Border.Background>
                                            <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                                <GradientStop Color="#FF222324" Offset="0"/>
                                                <GradientStop Color="#FF3D3E3E" Offset="0.716"/>
                                                <GradientStop Color="#FF2E2F2F" Offset="0.498"/>
                                            </LinearGradientBrush>

                                        </Border.Background>
                                        <ToggleButton MinHeight="0" MinWidth="0" x:Name="ExpanderButton" FontFamily="{TemplateBinding FontFamily}" FontSize="{TemplateBinding FontSize}" FontStretch="{TemplateBinding FontStretch}" FontStyle="{TemplateBinding FontStyle}" FontWeight="{TemplateBinding FontWeight}" HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" Template="{StaticResource ExpanderDownHeaderTemplate}" VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" Content="{TemplateBinding Header}" ContentTemplate="{TemplateBinding HeaderTemplate}" IsChecked="{TemplateBinding IsExpanded}" BorderBrush="{x:Null}" Padding="3,5,3,5" BorderThickness="0,0,0,0" Foreground="White"/>
                                    </Border>
                                    <ContentControl HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" x:Name="ExpandSite" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Visibility="Collapsed" FontFamily="{TemplateBinding FontFamily}" FontSize="{TemplateBinding FontSize}" FontStretch="{TemplateBinding FontStretch}" FontStyle="{TemplateBinding FontStyle}" FontWeight="{TemplateBinding FontWeight}" Foreground="{TemplateBinding Foreground}" HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" Grid.Column="0" Grid.Row="1" Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}" RenderTransformOrigin="0.5,0.5">
                                        <ContentControl.RenderTransform>
                                            <TransformGroup>
                                                <ScaleTransform/>
                                                <SkewTransform/>
                                                <RotateTransform/>
                                                <TranslateTransform Y="-35"/>
                                            </TransformGroup>
                                        </ContentControl.RenderTransform>
                                    </ContentControl>
                                </Grid>
                            </Border>
                            <Border x:Name="DisabledVisualElement" IsHitTestVisible="false" Opacity="0" Background="#A5FFFFFF"/>
                            <Border x:Name="FocusVisualElement" IsHitTestVisible="false" Visibility="Collapsed"/>
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
         
    </UserControl.Resources>

    <controls:Expander x:Name="statusExpander"  Collapsed="statusExpander_Collapsed"  VerticalAlignment="Top"  Style="{StaticResource StatusExpanderStyle}"

        Header="{Binding ConverterParameter=Status, Converter={StaticResource Localization}, Source={StaticResource Localization}}">
        <StackPanel  Orientation="Vertical" Background="#FF858483" Opacity="0.9" Height="Auto">
            <CheckBox x:Name="chkCritical" Margin="10,10,0,0"  Foreground="Black" FontWeight="Bold"  Tag="Critical" Content="{Binding ConverterParameter=enum_ConfStatus_Critical, Converter={StaticResource Localization}, Source={StaticResource Localization}}"/>
            <CheckBox x:Name="chkMajor" Margin="10,10,0,0"  Foreground="Black" FontWeight="Bold" Tag="Major" Content="{Binding ConverterParameter=enum_ConfStatus_Major, Converter={StaticResource Localization}, Source={StaticResource Localization}}" />
            <CheckBox x:Name="chkMinor" Margin="10,10,0,0" Foreground="Black" FontWeight="Bold" Tag="Minor" Content="{Binding ConverterParameter=enum_ConfStatus_Minor, Converter={StaticResource Localization}, Source={StaticResource Localization}}" />
            <CheckBox x:Name="chkNormal" Margin="10,10,0,0" Foreground="Black" FontWeight="Bold" Tag="Normal" Content="{Binding ConverterParameter=enum_EndpointStatus_Normal, Converter={StaticResource Localization}, Source={StaticResource Localization}}" />
            <CheckBox x:Name="chkUnknown" Margin="10,10,0,10" Foreground="Black" FontWeight="Bold" Tag="Unknown" Content="{Binding ConverterParameter=enum_EndpointStatus_Unknown, Converter={StaticResource Localization}, Source={StaticResource Localization}}" />
        </StackPanel>
    </controls:Expander>
</UserControl>



.CS



.CS

private void statusExpander_Collapsed ( object sender, RoutedEventArgs e ) {
               GetCheckedOptionList ();
                if ( SpaceStatusCheckedEvent != null ) {
                    SpaceStatusCheckedEvent ( sender, new EventArgs<List<EndpointStatus>> { Data =      lsCheckedOption, Ex = null } );
                }
        }
    }
}




When the statusExpander_Collapsed is called i have some functionality to be done.. but it shud be done after the dropdown is closed.. Now it is cald and the dropdown is stuck,after the functionality is done the dropdown gets closed.




When the statusExpander_Collapsed is called i have some functionality to be done.. but it shud be done after the dropdown is closed.. Now it is cald and the dropdown is stuck,after the functionality is done the dropdown gets closed.

推荐答案

You shouldn''t be tying up the UI thread for that long regardless of where the code is.

I would put that lengthy operation on a separate thread.
You shouldn''t be tying up the UI thread for that long regardless of where the code is.

I would put that lengthy operation on a separate thread.


Thanks a lot.. My issue is solved :) Threading works fine but can u tell me any other solution pls
Thanks a lot.. My issue is solved :) Threading works fine but can u tell me any other solution pls


这篇关于扩展器控件出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆