Bonjour,
Je veux databinder un contrôle, sur 2 propriétés. J'ai un contrôle hérité d'un TextBox et je le databinde avec la property TEXT. Jusqu'a la tout fonctionne.
Je créé, dans mon controle hérité, une property ControlValue. J'aimerai la databinder mais dans mon code XAML j'ai le message suivant: "La propriété ControlValue est introuvable dans le type 'CustomControl1'"
Code du contrôle hérité
Dans mon XAML de la forme cliente:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 Public Class CustomControl1 Inherits TextBox Public Shared ReadOnly ControlValueProperty As DependencyProperty = DependencyProperty.Register("ControlValue", GetType(String), GetType(CustomControl1)) Shared Sub New() 'This OverrideMetadata call tells the system that this element wants to provide a style that is different than its base class. 'This style is defined in Themes\Generic.xaml DefaultStyleKeyProperty.OverrideMetadata(GetType(CustomControl1), New FrameworkPropertyMetadata(GetType(CustomControl1))) End Sub Public Property ControlValue() As String Get Return GetValue(ControlValueProperty) End Get Set(ByVal value As String) SetValue(ControlValueProperty, value) End Set End Property End Class
...Mais ControlValue est introuvable donc ne compile pas ...
Code : Sélectionner tout - Visualiser dans une fenêtre à part <my:CustomControl1 Name="C1" Text="{Binding Path= Libelle.Value}" ControlValue="{Binding Path= Code.Value}" />
Si vous avez des idées je suis preneur. Merci d'avance.
Partager