(Using Silverlight 4.0 and VS 2010)
So I created a property called Rankin my C # file. How now to bind this to a control in the xaml UserControl file?
My code: (TopicListItem.xaml.cs)
#region Rank (DependencyProperty)
public int Rank
{
get { return (int)GetValue(RankProperty); }
set { SetValue(RankProperty, value); }
}
public static readonly DependencyProperty RankProperty =
DependencyProperty.Register("Rank", typeof(int), typeof(TopicListItem),
new PropertyMetadata(0, new PropertyChangedCallback(OnRankChanged)));
private static void OnRankChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
((TopicListItem)d).OnRankChanged(e);
}
protected virtual void OnRankChanged(DependencyPropertyChangedEventArgs e)
{
}
#endregion Rank (DependencyProperty)
I want to do this in my ThemeListItem.xaml
...
<Textblock Text="{TemplateBinding Rank}"/>
...
but it does not work.
source
share