C# 如何绑定到字符串中的样本数据?

C# 如何绑定到字符串中的样本数据?,c#,windows-phone-7,windows-phone,C#,Windows Phone 7,Windows Phone,我想将字符串绑定到示例数据。我可以绑定到代码隐藏,但它会在手机屏幕上闪烁,直到样本数据消失。我知道如何绑定到列表并在模拟预览中查看,但我不知道在示例数据中创建字符串的语法 下面是我的样本数据。我想给变量stringVar添加一个属性。它只是一根线 <local:ListPage xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.mi

我想将字符串绑定到示例数据。我可以绑定到代码隐藏,但它会在手机屏幕上闪烁,直到样本数据消失。我知道如何绑定到列表并在模拟预览中查看,但我不知道在示例数据中创建字符串的语法

下面是我的样本数据。我想给变量stringVar添加一个属性。它只是一根线

<local:ListPage
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"       
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:ListPage" >

    <local:ListPage.stringVar />
    <local:ListPage.ItemList>
        <local:Book id="0" title="item 1"/>
    </local:ListPage.ItemList>
</local:ListPage>

我建议在xaml中有一个资源

<local:ListPage
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"       
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:sys="clr-namespace:System;assembly=mscorlib"
    xmlns:local="clr-namespace:ListPage" >
    <local:ListPage.Resources>
        <sys:String x:Key="MyStaticString">Hello world!<sys:String>
    </local:ListPage.Resources>

    <local:ListPage.stringVar />
    <local:ListPage.ItemList>
        <local:Book id="0" title="{StaticResource MyStaticString}"/>
    </local:ListPage.ItemList>
</local:ListPage>

你好,世界!