Dependency property et Binding XAML
Bonjour,
j'ai un UserControl avec une image et je veux Binder l'url de l'image avec une propriété.
Code:
<Image x:Name="img" Source="{Binding}" Height="100" Width="100"/>
Je crée donc une Dependency property :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
|
public static readonly DependencyProperty URLProperty = DependencyProperty.Register("URL", typeof(string),typeof(UCImage), null);
public string URL
{
get { return (string)GetValue(URLProperty);}
set { SetValue(URLProperty, value);}
}
public UCImage()
{
// Requis pour initialiser des variables
InitializeComponent();
this.DataContext= URL;
} |
Pour autant, lorsque je modifie la valeur de URL, le control Image ne se Rebind pas ...
Bien sûr je connais la technique en passant par des OnxxxxChanged, mais je veux un binding par expression (XAML).
D'avance, merci pour votre aide.