Windows phone 7 如何在代码隐藏上设置绑定文本

Windows phone 7 如何在代码隐藏上设置绑定文本,windows-phone-7,Windows Phone 7,我创建了userControl,其中有两个textblock。我可以在xaml页面上设置使用此代码的文本 <my:Title Title TitleCaption="test On XMAL" /> }通过代码,您可以执行以下操作: PageTtile.Text = "This is from code"; // where PageTile is the x:Name of the TextBlock in XAML 可以用更简单的方法完成,您的财产应该是: pu

我创建了userControl,其中有两个textblock。我可以在xaml页面上设置使用此代码的文本

    <my:Title Title  TitleCaption="test On XMAL"   />

}

通过代码,您可以执行以下操作:

PageTtile.Text = "This is from code"; // where PageTile is the x:Name of the TextBlock in XAML

可以用更简单的方法完成,您的财产应该是:

public string TitleCaption
    {
        get
        {
            return PageTitle.Text;
        }
        set
        {
            PageTitle.Text=value;
        }
    }
现在,当您创建控件名称时:

<my:Title Name="myTitle"  TitleCaption="test On XMAL"   />

你应该投票,把对你帮助最大的答案标为最好的答案。这有助于帮助您的助手获得声誉:)。顺便说一下,不客气。。。。
public string TitleCaption
    {
        get
        {
            return PageTitle.Text;
        }
        set
        {
            PageTitle.Text=value;
        }
    }
<my:Title Name="myTitle"  TitleCaption="test On XMAL"   />
myTitle.TitleCaption="your Text Goes Here";