C# 如何将数据绑定到用户控件WP8并在其中注册属性

C# 如何将数据绑定到用户控件WP8并在其中注册属性,c#,xaml,user-controls,windows-phone-8,C#,Xaml,User Controls,Windows Phone 8,我有一个用户控件: <UserControl> <Grid Name="grid1" Background="#1133CC" Canvas.ZIndex="1" Width="200" Height="200"> <Image Name="img1" Source="{Binding ImageSource}" /> <TextBlock Text="{Binding Title"}/> </Gri

我有一个用户控件:

<UserControl>
<Grid Name="grid1" Background="#1133CC" Canvas.ZIndex="1" Width="200" Height="200">

        <Image Name="img1" Source="{Binding ImageSource}" />
        <TextBlock Text="{Binding Title"}/>
    </Grid>
</UserControls>

标题:字符串 图像源:位图图像

如何在MainPage.xaml中使用绑定数据,如:

<Grid>
<local:myUserControl Title="{Binding Title"} ImageSoure="{Binding ImageSource}" />
</Grid>


怎么做?谢谢

听起来你基本上是在问“我该怎么做绑定”。一个好的读物是:以及您在那里找到的几乎所有其他绑定资源

在本例中,您需要一个对象,该对象具有
标题
图像源
属性,该属性设置为控件的
数据上下文
(或其父对象之一,如
PhoneApplicationPage
)。您可以从代码隐藏(或在XAML中)设置
DataContext
(如果您在页面上,则可以简单地设置
DataContext=…