Setter.Target给我一个"RelativePanel.AlignHorizontalCenterWithPanel"错误. [英] Setter.Target give me an error with "RelativePanel.AlignHorizontalCenterWithPanel"
问题描述
我正在开发UWP应用,并且正在使用Template10.
我有一个TextBlock
,在VisualStateNarrow
中我想要它RelativePanel.AlignVerticalCenterWithPanel="True"
,在NormalMinWidth
中我想要RelativePanel.AlignHorizontalCenterWithPanel="True"
,但是我不能这样做!
I am develop an UWP app, and I am using Template10.
I have an TextBlock
, that in VisualStateNarrow
I want it RelativePanel.AlignVerticalCenterWithPanel="True"
and in NormalMinWidth
I want RelativePanel.AlignHorizontalCenterWithPanel="True"
but I can not do this!
<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.AlignHorizontalCenterWithPanel."
In XAML editor give me this error: "An Exception was thrown." - "Cannot resolve TargetProperty RelativePanel.AlignHorizontalCenterWithPanel on specified object."
我有很多Setter.Target,它们都可以工作! 我的Setter.Target的示例:
I have many Setter.Target and they all work! Example of my Setter.Target:
<Setter Target="TextBlock.Margin" Value="8"/>
<Setter Target="TextBlock.Width" Value="200"/>
<Setter Target="TextBlock.Height" Value="200"/>
推荐答案
对于附加属性,您必须按如下方法在方括号中添加方括号:
For attached properties you have to add brackets to in setters as follows:
Element.(Grid.Row)
Element.(ToolTipService.ToolTip)
因此您的代码将如下所示:
So your code will look like this:
<Setter Target="TextBlock.(RelativePanel.AlignVerticalCenterWithPanel)" Value="True" />
这篇关于Setter.Target给我一个"RelativePanel.AlignHorizontalCenterWithPanel"错误.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!