gpt4 book ai didi

c# - Setter.Target 给我一个错误 "RelativePanel.AlignHorizontalCenterWithPanel"

转载 作者:太空宇宙 更新时间:2023-11-03 19:46:51 24 4
gpt4 key购买 nike

我正在开发一个 UWP 应用程序,我正在使用 Template10。我有一个 TextBlock,在 VisualStateNarrow 我想要它 RelativePanel.AlignVerticalCenterWithPanel="True"NormalMinWidth 我想要 RelativePanel.AlignHorizo​​ntalCenterWithPanel="True" 但我做不到!

<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="AdaptiveVisualStateGroup">
<VisualState x:Name="VisualStateNarrow">
<VisualState.StateTriggers>
<AdaptiveTrigger MinWindowWidth="{StaticResource NarrowMinWidth}"/>
</VisualState.StateTriggers>
<VisualState.Setters>

<Setter Target="TextBlock.RelativePanel.AlignVerticalCenterWithPanel="True"/>

</VisualState.Setters>
</VisualState>
<VisualState x:Name="VisualStateNormal">
<VisualState.StateTriggers>
<AdaptiveTrigger MinWindowWidth="{StaticResource NormalMinWidth}"/>
</VisualState.StateTriggers>
<VisualState.Setters>

<Setter Target="TextBlock.RelativePanel.AlignHorizontalCenterWithPanel="True"/>

</VisualState.Setters>
</VisualState>
<VisualState x:Name="VisualStateWide">
<VisualState.StateTriggers>
<AdaptiveTrigger MinWindowWidth="{StaticResource WideMinWidth}"/>
</VisualState.StateTriggers>
<VisualState.Setters>
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>

在 XAML 编辑器中给我这个错误:“抛出异常。” - “无法解析指定对象上的 TargetProperty RelativePanel.AlignHorizo​​ntalCenterWithPanel。”

我有很多 Setter.Target,它们都可以工作!我的 Setter.Target 示例:

<Setter Target="TextBlock.Margin" Value="8"/>
<Setter Target="TextBlock.Width" Value="200"/>
<Setter Target="TextBlock.Height" Value="200"/>

最佳答案

这是一种无需编写任何代码即可为自适应触发器 创 build 置器的方法。由于 VS 既不提供 IntelliSense 也不提供编写它们的错误警告,这有助于防止难以诊断的错误。

  1. 转到状态面板,单击以激活您要向其添加 setter 的视觉状态。一个红点会出现在这个视觉状态的名称旁边。
  2. 激活后,转到对象和时间轴 面板并选择您要在此状态下进行交互的元素。在您的情况下,选择 TextBlock 元素。
  3. 转到Properties 面板,展开RelativePanel 部分或在搜索框中搜索“relative”,出现属性后,只需选择您想要的想要改变。

就是这样!也可以随意查看下面的 gif 演示。

enter image description here

关于c# - Setter.Target 给我一个错误 "RelativePanel.AlignHorizontalCenterWithPanel",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44475251/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com