2012-12-04 35 views
0

我想將一個字符串綁定到示例數據。我可以綁定到代碼隱藏功能,但它會在手機屏幕上閃爍,直到示例數​​據消失。我知道如何綁定到列表並查看在模擬預覽中,我不知道用於在示例數據中創建字符串的語法。如何綁定到字符串中的示例數據?

以下是我的示例數據。我想向名爲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> 

回答

0

我建議在你的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> 
相關問題