windows phone 7 - How to set the binding text on code behind -


I have created a user Control which two Tekstblok I can I set text xaml page to use this code .

  & lt; My: Title Title TitleCaption = "test on XMAL" />   

Although I want to set the value of the text of the code Will someone show me how to get this work done? . Thanks in advance

My UserControl is:

  & lt; UserControl x: Name = "TitleSection" x: Class = "CMSPhoneApp.Title" xmlns = "http: //schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns: x = "http://schemas.microsoft .com / winfx / 2006 / xaml "xmlns: d =" http://schemas.microsoft.com/compilation / mix / 2008 "xmlns: mc =" http://schemas.openxmlformats.org/markup-compatibility/ 2006 "MC: ignore usable =" D "FontFamily =" {StaticResource PhoneFontFamilyNormal} "fONTSIZE =" {StaticResource PhoneFontSizeNormal} "foreground =" {StaticResource PhoneForegroundBrush} "d: DesignHeight =" 480 "D: DesignWidth =" 480 " & Gt; & Lt; Grid X: Name = "Layouts" style = "{static resource gridtitle style 1}" & gt; & Lt; StackPanel & gt; & Lt; TextBlock x: name = "appliancetytile" width = "350" text = "mypethetic" horizontal align = "left" is font size = "20" & gt; & Lt; TextBlock.Foreground & gt; & Lt; Solid color brush color = "#fffff" /> & Lt; /TextBlock.Foreground> & Lt; / TextBlock & gt; & Lt; TextBlock x: Name = "PageTtile" style = "{StaticResource TitleTextBlockStyle}" Text = "{Binding Path = TitleCaption, mode = TwoWay, ElementName = TitleSection}" & gt; & Lt; / TextBlock & gt; & Lt; / StackPanel & gt; & Lt; / Grid & gt;   

The following is behind the page code:

  namespace CMSPhoneApp {public partial class title: UserControl {public Title () {initial group (); } Public static DependencyProperty TitleCaptionProperty = DependencyProperty.Register ("TitleCaption", typeof (string), typeof (title), null); Public String Title Caption {get {return (string) GetValue (TitleCaptionProperty); } Set {set value (title caption property, value); }}}   

}

This can be done in one It is a very easy way to have your property:

  public string title caption {get {return PageTitle.Text; } Set {PageTitle.Text = value; }}   

Now when you make it a control name:

  & lt; My: Title Name = "myTitle" TitleCaption = "Test at XMAL" />   

Now you can change the following code PageTitle codes:

  myTitle.TitleCaption = "Your text goes here";    

Comments