网格中的元素不会改变位置 [英] Elements in a Grid do not change position

查看:68
本文介绍了网格中的元素不会改变位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在xaml文件中声明了一个Grid。在网格内部有一个名为"notetaking"的richtext组件。


在使用模拟进行调试之后,我想将屏幕旋转90度并将布局更改为Portrait。


具体来说,我想移动"注意事项"。另一个网格列和行中的组件。


所以我在网格定义下使用了下面的代码而它没有用。


代码如下,我看不出错误......



特定richtextbox元素的定义是否需要绑定?



提前致谢


       &NBSP;&NBSP;&NBSP;&NBSP;&NBSP; < VisualStateManager.VisualStateGroups>

&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; < VisualStateGroup X:名称= QUOT; ApplicationViewStates">

&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP ;&NBSP;&NBSP;&NBSP;&NBSP; <的VisualState X:名称= QUOT; DefaultLayout">

&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP ;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; < VisualState.StateTriggers>

&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; &NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; < triggers:LayoutTrigger LayoutState =" Landscape" />

&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP ;&NBSP;&NBSP;&NBSP; < /VisualState.StateTriggers>

&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP ;&NBSP; < / VisualState>



                 ;&NBSP;&NBSP;&NBSP;&NBSP; < VisualState x:Name =" PortraitLayout">





&NBSP; < VisualState.StateTriggers>

&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; &NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; < triggers:LayoutTrigger LayoutState =" Portrait" />

&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP ;&NBSP;&NBSP;&NBSP; < /VisualState.StateTriggers>

&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP ;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; <故事板>

&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; &NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; < ObjectAnimationUsingKeyFrames Storyboard.TargetName =" notetaking" Storyboard.TargetProperty = QUOT;(Grid.Row)">

&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP ;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; < DiscreteObjectKeyFrame KeyTime =" 0"值= QUOT; 9" />

&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP ;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; < / ObjectAnimationUsingKeyFrames>



&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP ;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; < ObjectAnimationUsingKeyFrames Storyboard.TargetName =" notetaking" Storyboard.TargetProperty = QUOT;(Grid.Column)">

&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP ;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; < DiscreteObjectKeyFrame KeyTime =" 0"值= QUOT; 3英寸/>

&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP ;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; < / ObjectAnimationUsingKeyFrames>



&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP ;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; <! - < ObjectAnimationUsingKeyFrames Storyboard.TargetName =" searchUserControl" Storyboard.TargetProperty = QUOT;(观点:SearchUserControl.IsCompact)">

&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP ;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; < DiscreteObjectKeyFrame KeyTime = QUOT; 0">

&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP ;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; < DiscreteObjectKeyFrame.Value>

&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; &NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; < X:布尔>真< / X:布尔>

&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP ;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; < /DiscreteObjectKeyFrame.Value>

&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP ;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; < / DiscreteObjectKeyFrame>

&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP ; < / ObjectAnimationUsingKeyFrames> - >

&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP ;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; < /故事板>

&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP ; < / VisualState>



                 ; < / VisualStateGroup>&
            < /VisualStateManager.VisualStateGroups>







&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;

解决方案

嗨Michelle Fran,


欢迎来到开发通用Windows应用论坛! 


请阅读粘性帖子,尤其是  Guide
到发帖:主题行标签
 和  Windows 10 SDK和工具的已知问题 


我无法重现您的问题。


控制作者或应用开发者添加VisualStateGroup对象元素在XAML控制模板定义的根元素,使用附加属性的VisualStateManager.VisualStateGroups。


'p>有关的详细信息,请参阅VisualStateManager在此链接:&NBSP; https://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.visualstatemanager.aspx


请检查如果VisualStateManager没有在Grid的根目录中设置。您应该能够将VisualStateManager放在网格的根目录中。 


例如:

< Grid Background =" {ThemeResource ApplicationPageBackgroundThemeBrush}"> 
< VisualStateManager.VisualStateGroups>
< VisualStateGroup x:Name =" ApplicationViewStates">
< VisualState x:Name =" DefaultLayout">
< VisualState.StateTriggers>
< triggers:LayoutTrigger LayoutState =" Landscape" />
< /VisualState.StateTriggers>
< / VisualState>
< VisualState x:Name =" PortraitLayout">
< VisualState.StateTriggers>
< triggers:LayoutTrigger LayoutState =" Portrait" />
< /VisualState.StateTriggers>
< Storyboard>
< ObjectAnimationUsingKeyFrames Storyboard.TargetName =" notetaking" Storyboard.TargetProperty = QUOT;(Grid.Row)">
< DiscreteObjectKeyFrame KeyTime =" 0"值= QUOT; 9" />
< / ObjectAnimationUsingKeyFrames>
< ObjectAnimationUsingKeyFrames Storyboard.TargetName =" notetaking" Storyboard.TargetProperty = QUOT;(Grid.Column)">
< DiscreteObjectKeyFrame KeyTime =" 0"值= QUOT; 3英寸/>
< / ObjectAnimationUsingKeyFrames>
< / Storyboard>
< / VisualState>
< / VisualStateGroup>
< /VisualStateManager.VisualStateGroups>
< Grid.ColumnDefinitions>
< ColumnDefinition Width =" *" />
< ColumnDefinition Width =" *" />
< ColumnDefinition Width =" *" />
< ColumnDefinition Width =" *" />
< /Grid.ColumnDefinitions>
< Grid.RowDefinitions>
< RowDefinition Height =" *" />
< RowDefinition Height =" *" />
< RowDefinition Height =" *" />
< RowDefinition Height =" *" />
< RowDefinition Height =" *" />
< RowDefinition Height =" *" />
< RowDefinition Height =" *" />
< RowDefinition Height =" *" />
< RowDefinition Height =" *" />
< RowDefinition Height =" *" />
< /Grid.RowDefinitions>
< RichTextBlock Grid.Row =" 0" Grid.Column = QUOT; 0"名称= QUOT;笔记与QUOT;余量= QUOT; 0,12,0,0">
<段落>预期:静默定位4个图块,您可以将其调整为小,中,宽和大,这样您就可以看到所有的一次。< / Paragraph>
< / RichTextBlock>
< / Grid>

最好的问候,


Jayden Gu


In a xaml file there is a Grid declared. Inside the grid there is a richtext component named "notetaking".

After Debugging with the simulation I want to rotate the screen 90 degrees and change the layout to Portrait.

Specifically, I want to move the "notetaking" component in another grid column and row.

So I used the code below under the grid definitions and it is not working.

The code is below, I cannot see the mistake...

Is a Binding needed in the definition of the particular richtextbox element?

Thanks in advance

            <VisualStateManager.VisualStateGroups>
                <VisualStateGroup x:Name="ApplicationViewStates">
                    <VisualState x:Name="DefaultLayout">
                        <VisualState.StateTriggers>
                            <triggers:LayoutTrigger LayoutState="Landscape" />
                        </VisualState.StateTriggers>
                    </VisualState>

                    <VisualState x:Name="PortraitLayout">


  <VisualState.StateTriggers>
                            <triggers:LayoutTrigger LayoutState="Portrait" />
                        </VisualState.StateTriggers>
                        <Storyboard>
                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="notetaking" Storyboard.TargetProperty="(Grid.Row)">
                                <DiscreteObjectKeyFrame KeyTime="0" Value="9" />
                            </ObjectAnimationUsingKeyFrames>

                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="notetaking" Storyboard.TargetProperty="(Grid.Column)">
                                <DiscreteObjectKeyFrame KeyTime="0" Value="3" />
                            </ObjectAnimationUsingKeyFrames>

                            <!--<ObjectAnimationUsingKeyFrames Storyboard.TargetName="searchUserControl" Storyboard.TargetProperty="(views:SearchUserControl.IsCompact)">
                        <DiscreteObjectKeyFrame KeyTime="0">
                            <DiscreteObjectKeyFrame.Value>
                                <x:Boolean>True</x:Boolean>
                            </DiscreteObjectKeyFrame.Value>
                        </DiscreteObjectKeyFrame>
                    </ObjectAnimationUsingKeyFrames>-->
                        </Storyboard>
                    </VisualState>

                </VisualStateGroup>
            </VisualStateManager.VisualStateGroups>


                      

解决方案

Hi Michelle Fran,

Welcome to the Developing Universal Windows apps forum! 

Please read the sticky posts, especially the Guide to posting: subject line tags and Known Issues for Windows 10 SDK and Tools .

I can not reproduce your issue.

Control authors or app developers add VisualStateGroup object elements to the root element of a control template definition in XAML, using the VisualStateManager.VisualStateGroups attached property.

For more info, see VisualStateManager in this link: https://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.visualstatemanager.aspx.

Plese check with that if the VisualStateManager does not set in the root of the Grid. You should able to put the VisualStateManager in the root of the Grid. 

For example:

<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
    <VisualStateManager.VisualStateGroups>
        <VisualStateGroup x:Name="ApplicationViewStates">
            <VisualState x:Name="DefaultLayout">
                <VisualState.StateTriggers>
                    <triggers:LayoutTrigger LayoutState="Landscape" />
                </VisualState.StateTriggers>
            </VisualState>
            <VisualState x:Name="PortraitLayout">
                <VisualState.StateTriggers>
                    <triggers:LayoutTrigger LayoutState="Portrait" />
                </VisualState.StateTriggers>
                <Storyboard>
                    <ObjectAnimationUsingKeyFrames Storyboard.TargetName="notetaking" Storyboard.TargetProperty="(Grid.Row)">
                        <DiscreteObjectKeyFrame KeyTime="0" Value="9" />
                    </ObjectAnimationUsingKeyFrames>
                    <ObjectAnimationUsingKeyFrames Storyboard.TargetName="notetaking" Storyboard.TargetProperty="(Grid.Column)">
                        <DiscreteObjectKeyFrame KeyTime="0" Value="3" />
                    </ObjectAnimationUsingKeyFrames>
                </Storyboard>
            </VisualState>
        </VisualStateGroup>
    </VisualStateManager.VisualStateGroups>
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="*" />
        <ColumnDefinition Width="*" />
        <ColumnDefinition Width="*" />
        <ColumnDefinition Width="*" />
    </Grid.ColumnDefinitions>
    <Grid.RowDefinitions>
        <RowDefinition Height="*" />
        <RowDefinition Height="*" />
        <RowDefinition Height="*" />
        <RowDefinition Height="*" />
        <RowDefinition Height="*" />
        <RowDefinition Height="*" />
        <RowDefinition Height="*" />
        <RowDefinition Height="*" />
        <RowDefinition Height="*" />
        <RowDefinition Height="*" />
    </Grid.RowDefinitions>
    <RichTextBlock Grid.Row="0"  Grid.Column="0" Name="notetaking" Margin="0,12,0,0">
        <Paragraph>Expected: Silently pins 4 tiles, which you can resize to small, medium, wide, and large, so you can see all all once.</Paragraph>
    </RichTextBlock>
</Grid>

Best Regards,

Jayden Gu


这篇关于网格中的元素不会改变位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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