J'ai un contrôle simple utilisateurSilverlight UserControl Reliure
Xaml:
<UserControl x:Class="GraemeGorman_Controls.Navigation.NavigationItem"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Border x:Name="borderLayoutRoot">
<TextBlock x:Name="textBlockCaption" Text="{Binding Caption}" />
</Border>
</UserControl>
Cs:
namespace GraemeGorman_Controls.Navigation
{
public partial class NavigationItem : UserControl
{
public static readonly DependencyProperty CaptionProperty = DependencyProperty.Register(
"Caption",
typeof (string),
typeof (NavigationItem),
new PropertyMetadata(new PropertyChangedCallback(OnCaptionChanged)));
public string Caption
{
get {return (string)GetValue(CaptionProperty);}
set {SetValue(CaptionProperty, value);}
}
public NavigationItem()
{
InitializeComponent();
}
private static void OnCaptionChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
//null
}
}
}
Ce que ma question est, quand je crée une instance de contrôle la légende ne montre - maintenant j'ai testé la propriété dans la fonction OnCaptionChanged en utilisant e.NewValue et c'est la valeur correcte. Quel est le problème avec ma liaison?
Si je vous écris dans le code derrière la propriété de légende pour voir
textBlockCaption.Text = value;
Il semble bien ...
Toute aide appréciée
Merci Graeme
Salut C'était exactement ça !!! Merci! –
Si vous modifiez DataContext, vous ne pourrez pas utiliser la liaison de données d'un niveau supérieur (au format où UserControl est utilisé) – Grigory