I found the solution by myself. I need to register DependencyProperty. There is my code.
PageTitle.xaml
Code:
<UserControl x:Name="TitleControl" x:Class="PhoneApp1.PageTitle"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
d:DesignHeight="480" d:DesignWidth="480">
<Grid x:Name="LayoutRoot" >
<StackPanel x:Name="TitlePanel" Margin="4,17,10,28" Grid.Column="1" >
<TextBlock x:Name="ApplicationTitle" Text="CSM Phone Application" Style="{StaticResource appTitleStyle}" />
<Grid Height="45" Style="{StaticResource pageTitleBackgroudStyle}">
<TextBlock Text="{Binding Path=TitleCaption, ElementName=TitleControl }" Style="{StaticResource pageTitleStyle}"
TextAlignment="{Binding}" />
</Grid>
</StackPanel>
</Grid>
</UserControl>
The code behind of the PageTitle.xaml
Code:
//http://alan.beech.me.uk/2011/04/25/adding-a-dependency-property-to-a-wp7-usercontrol/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
namespace PhoneApp1
{
public partial class PageTitle : UserControl
{
public PageTitle()
{
InitializeComponent();
}
public static DependencyProperty TitleCaptionProperty =
DependencyProperty.Register("TitleCaption", typeof(string), typeof(PageTitle), null);
public string TitleCaption
{
get
{
return (string)GetValue(TitleCaptionProperty);
}
set
{
SetValue(TitleCaptionProperty, value);
}
}
}
}
On the mainPage.xml
Code:
<StackPanel x:Name="Titleqq" Grid.Row="0" Margin="12,17,0,28" Grid.ColumnSpan="2" >
<my:PageTitle TitleCaption="LOGIN" />