【发布时间】:2013-02-16 12:38:18
【问题描述】:
我遇到了 TextBlock/TextBox 绑定问题。 TextBlock 不显示属性的内容。当我调试我的应用程序时,属性有内容。你怎么能做到? Xaml。
<TextBlock HorizontalAlignment="Left" Margin="730,191,0,0" TextWrapping="Wrap" Text="{Binding XmlContentFile, Mode=TwoWay}" VerticalAlignment="Top" Height="429" Width="465"/>
我在网上寻找简单的代码,但我没有找到代码。
代码属性
public string XmlContentFile
{
get
{
return this.xmlContentFile;
}
set
{
this.xmlContentFile = value;
}
}
我的数据上下文
DataContext="{Binding Main, Source={StaticResource Locator}}">
方法加载 XML 文件到字符串变量
public async void XmlContentLoad()
{
if (selectFile != null)
{
try
{
StorageFolder storageFolder = ApplicationData.Current.LocalFolder;
StorageFile storageFile = await storageFolder.GetFileAsync(selectFile);
xmlFileTextContent = await FileIO.ReadTextAsync(storageFile);
}
catch (Exception)
{
throw new Exception("Bug");
}
}
}
【问题讨论】:
-
这是 WPF 还是 Windows 8 应用商店应用?
-
这可能会有所帮助:blog.jerrynixon.com/2012/08/…
标签: c# xaml windows-8 mvvm-light