如何在Windows Apps中更改RelativePanel附加属性?

时间:2015-03-29 06:55:48

标签: xaml win-universal-app windows-10 attached-properties uwp-xaml

我曾尝试在Visual State.Setters中以可视状态更改XAML控件的RelativePanel附加属性,但属性不会更改,因此我创建了一个依赖项属性,以便通过代码进行测试,而不是。

有没有办法刷新一组新的值,如:

 <VisualState.Setters>
      <Setter Target="TimestablesControl.RelativePanel.RightOf" Value=""/>
      <Setter Target="TimestablesControl.RelativePanel.AlignRightWithPanel" Value="false"/>
      <Setter Target="TimestablesControl.RelativePanel.AlignLeftWithPanel" Value="true"/> 
 </VisualState.Setters>

让视图更具响应性&#39;

1 个答案:

答案 0 :(得分:8)

要在Setter.Target中更改附加属性的值,请使用以下格式:

TargetObjectXName.(ClassName.AttachedPropertyName)

在你的情况下:

 <VisualState.Setters>
      <Setter Target="TimestablesControl.(RelativePanel.RightOf)" Value="Control1"/>
      <Setter Target="TimestablesControl.(RelativePanel.AlignRightWithPanel)" Value="False"/>
      <Setter Target="TimestablesControl.(RelativePanel.AlignLeftWithPanel)" Value="True"/> 
 </VisualState.Setters>

其中“Control1”是x:您想要放置在TimestablesControl左侧的控件的名称。