我们如何将枚举绑定到 a TextBlock
?
在代码隐藏中,我有:
public enum SpeechStateEnumeration
{
Listening,
Recording,
Dictating,
Working,
Sleeping,
Unresponsive
}
public static SpeechStateEnumeration SpeechState;
button1_Click(object sender, EventArgs e)
{
SpeechState = SpeechStateEnumeration.Sleeping;
}
我的 XAML 是:
<TextBlock x:Name="Status" Text="{Binding SpeechState}" />
但它不起作用。例如,如果我设置SpeechState
为“聆听”或“睡眠”,我如何通过TextBlock
?