我目前在数据透视控制页面上使用多个文本块,但我无法更改文本块的值。原因是"名称' XXX'在当前背景下不存在"即使我已经为要写入的值命名了我的文本块。 我可以在使用普通应用程序页面时更改值,但pivot不允许我这样做。有什么办法可以解决这个问题吗?
<ScrollViewer>
<Grid x:Name="LayoutRoot" Background="Transparent" Height="768" Width="480">
<!--Pivot Control-->
<phone:Pivot Title="MY APPLICATION" Loaded="Pivot_Loaded">
<!--Pivot item one-->
<phone:PivotItem Header="Stats">
<Border
BorderBrush="{StaticResource PhoneBackgroundBrush}"
BorderThickness="{StaticResource PhoneBorderThickness}" Background="Black">
<Grid Margin="-3,75,-17,-75">
<TextBlock
TextWrapping="Wrap"
Style="{StaticResource PhoneTextExtraLargeStyle}" Margin="10,121,253,422" FontSize="30" Text="Highest Temp : " />
<TextBlock
TextWrapping="Wrap"
Style="{StaticResource PhoneTextExtraLargeStyle}" Margin="10,0,253,551" Text="Current Temp :" FontSize="30" />
<TextBlock
TextWrapping="Wrap"
Style="{StaticResource PhoneTextExtraLargeStyle}" Margin="10,240,253,311" Text="Lowest Temp : " FontSize="30" />
<TextBlock
TextWrapping="Wrap"
Style="{StaticResource PhoneTextExtraLargeStyle}" Margin="10,360,253,191" Text="Average Temp : " FontSize="30" />
<TextBlock x:Name="TempAverage"
TextWrapping="Wrap"
Style="{StaticResource PhoneTextExtraLargeStyle}" Margin="222,360,41,191" Text="-" FontSize="30" />
<TextBlock x:Name="TempLowest"
TextWrapping="Wrap"
Style="{StaticResource PhoneTextExtraLargeStyle}" Margin="222,240,41,311" Text="-" FontSize="30" />
<TextBlock x:Name="TempHighest"
TextWrapping="Wrap"
Style="{StaticResource PhoneTextExtraLargeStyle}" Margin="222,121,41,430" Text="-" FontSize="30" />
<TextBlock x:Name="TempCurrent"
TextWrapping="Wrap"
Style="{StaticResource PhoneTextExtraLargeStyle}" Margin="222,0,41,551" Text="-" FontSize="30" />
</Grid>
</Border>
这是我的cs代码
if(TempRandom2 > Max)
{
Max = TempRandom2; //Highest Temp = Current Temp
TempHighest.Text = Max.ToString("0.0");
}
if(TempRandom2 < Min)
{
Min = TempRandom2;
TempLowest.Text = Min.ToString("0.0"); //Lowest Temp = Current Temp
}
AvgTemp[a++ % 100] = TempRandom2;
if (a > 100)
TempAverage.Text = AvgTemp.Average().ToString("0.0");
else
TempAverage.Text = (AvgTemp.Sum() / a).ToString("0.0");
}
}
}