我面临一个奇怪的问题,我在StackLayout中有一个标签,它位于相对布局中,如下所示:
<RelativeLayout Margin="0,10,0,10">
<localShapes:ShapeView WidthRequest="100"
HeightRequest="100"
Progress="100"
ShapeType="ProgressCircle"
Color="#f1f1f1" BorderColor="#d2d2d2"
ProgressBorderColor="#f1b035"
ProgressBorderWidth="12"
BorderWidth="12"
RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToParent,Property=Width, Factor=.5, Constant = -50}" />
<StackLayout Spacing="0"
BackgroundColor="Gray"
Orientation="Vertical"
VerticalOptions="Center"
RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent,Property=Width, Factor=1, Constant = 0}"
RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent,Property=Height, Factor=1, Constant = 0}">
<localControls:LocalizedLabel
BackgroundColor="Blue"
Text="{Binding UserScore}"
FontSize="16"
FontAttributes="Bold"
TextColor="#303030"
TextAlignment="Center"
VerticalOptions="Center"
HorizontalOptions="Center" />
<localControls:LocalizedLabel
Text="{appResources:Translate Points}"
FontSize="9"
TextColor="#303030"
TextAlignment="Center"
VerticalOptions="Center"
HorizontalOptions="Center" />
</StackLayout>
</RelativeLayout>
所以当我输入硬编码值时,如下面的代码片段
<localControls:LocalizedLabel BackgroundColor="Blue"
Text="20"
FontSize="16"
FontAttributes="Bold"
TextColor="#303030"
TextAlignment="Center"
VerticalOptions="Center"
HorizontalOptions="Center" />
它在正确的位置显示标签 .
但是当我在我的ViewModel中将Label绑定到value时,就会显示出来
哪个不对 . 那么我该如何解决这个问题呢?