【发布时间】:2017-07-31 01:38:33
【问题描述】:
刚开始在 c# 中并想创建简单的 UWP 应用程序,我有 TextBlock 和 Button,我想在按下 Button 时 TextBlock 文本更改但总是出错:
private void Button_Click(object sender, RoutedEventArgs e)
{
TextBlock Text = "HELLO";
}
CS0029 C# 无法将类型“字符串”隐式转换为“windows.ui.xaml.controls.textblock”
我很困惑,为什么文本字段不理解字符串。
感谢您的帮助。
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Button Content="Button" HorizontalAlignment="Left" Height="50" Margin="105,306,0,0" VerticalAlignment="Top" Width="146" Click="Button_Click"/>
<TextBlock HorizontalAlignment="Left" Margin="56,141,0,0" TextWrapping="Wrap" Text="TextBlock" VerticalAlignment="Top" Height="107" Width="241" SelectionChanged="TextBlock_SelectionChanged" FontSize="36"/>
</Grid>
【问题讨论】:
标签: c# xaml uwp type-conversion