0

我想为 Visual Studio 记录混合状态,但是当我为某个状态调整窗口(网格和选项卡控件)的大小时,整个内容都会被扭曲。如果我不记录,那么它将表现正常。

在此处输入图像描述 形式的基本状态

在此处输入图像描述 这就是我调整大小时发生的情况

这是xaml代码

 <Window x:Name="window" x:Class="WpfApp2.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:local="clr-namespace:WpfApp2"
    mc:Ignorable="d"
    Title="MainWindow" Height="208" Width="220">

<Grid x:Name="grid" HorizontalAlignment="Left" Width="213" Margin="0,0,-1,0" RenderTransformOrigin="0.5,0.5">

    <Grid.RenderTransform>
        <TransformGroup>
            <ScaleTransform/>
            <SkewTransform/>
            <RotateTransform/>
            <TranslateTransform/>
        </TransformGroup>
    </Grid.RenderTransform>

    <VisualStateManager.VisualStateGroups>
        <VisualStateGroup x:Name="VisualStateGroup">
            <VisualStateGroup.Transitions>
                <VisualTransition From="big" GeneratedDuration="0:0:1"/>
            </VisualStateGroup.Transitions>
            <VisualState x:Name="big">
                <Storyboard>
                    <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Width)" Storyboard.TargetName="window">
                        <EasingDoubleKeyFrame KeyTime="0" Value="339"/>
                    </DoubleAnimationUsingKeyFrames>
                    <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)" Storyboard.TargetName="grid">
                        <EasingDoubleKeyFrame KeyTime="0" Value="1.549"/>
                    </DoubleAnimationUsingKeyFrames>
                    <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)" Storyboard.TargetName="grid">
                        <EasingDoubleKeyFrame KeyTime="0" Value="58.5"/>
                    </DoubleAnimationUsingKeyFrames>
                    <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)" Storyboard.TargetName="tabControl">
                        <EasingDoubleKeyFrame KeyTime="0" Value="1.33"/>
                    </DoubleAnimationUsingKeyFrames>
                    <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)" Storyboard.TargetName="tabControl">
                        <EasingDoubleKeyFrame KeyTime="0" Value="35.184"/>
                    </DoubleAnimationUsingKeyFrames>
                </Storyboard>
            </VisualState>
        </VisualStateGroup>
    </VisualStateManager.VisualStateGroups>

    <TabControl x:Name="tabControl" SelectionChanged="changes" Height="177" VerticalAlignment="Top" RenderTransformOrigin="0.5,0.5">

        <TabControl.RenderTransform>
            <TransformGroup>
                <ScaleTransform/>
                <SkewTransform/>
                <RotateTransform/>
                <TranslateTransform/>
            </TransformGroup>
        </TabControl.RenderTransform>

        <TabItem Header="TabItem" Name="tab1">
            <TextBlock HorizontalAlignment="Center" TextWrapping="Wrap" VerticalAlignment="Center"  Width="163.126" Height="55.88" Text="apple cat bol dog gellephant this is sample only"/>

        </TabItem>
        <TabItem Header="TabItem" Name="tab2">
        </TabItem>
    </TabControl>

</Grid>

请帮忙。任何帮助将非常感激。

4

1 回答 1

0

我自己找到了答案。

代替

 <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)" Storyboard.TargetName="grid">
                    <EasingDoubleKeyFrame KeyTime="0" Value="1.549"/>
 </DoubleAnimationUsingKeyFrames>

我不得不使用

 <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Width)" Storyboard.TargetName="grid">
                        <EasingDoubleKeyFrame KeyTime="0" Value="909"/>
 </DoubleAnimationUsingKeyFrames>

我不得不使用 FrameworkElement 而不是 UIElements。

于 2017-09-27T06:41:09.130 回答