Probleme CustomControl Textbox
Bonjour,
Voila j'ai un petit problème, je me lance dans les app wpf, et j'aimerai créer un textbox personnalisé.
Donc je rajoute un élément à mon projet, (wpf/custom control)
J'obtiens une classe avec ce code :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
Imports System.Windows.Controls.Primitives
Public Class TextBoxcustom
Inherits System.Windows.Controls.TextBox
Shared Sub New()
'Cet appel OverrideMetadata indique au système que cet élément souhaite apporter un style différent de celui de sa classe de base.
'Ce style est défini dans themes\generic.xaml
DefaultStyleKeyProperty.OverrideMetadata(GetType(TextBoxcustom), new FrameworkPropertyMetadata(GetType(TextBoxcustom)))
End Sub
End Class |
Le code xaml generic :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:WpfApplication1">
<Style TargetType="{x:Type local:TextBoxcustom}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type local:TextBoxcustom}">
<Border Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}">
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary> |
Et ceci dans mainwindow.xaml
Code:
1 2 3
|
xmlns:MyNamespace="clr-namespace:WpfApplication1" |
Ensuite je génère mon projet, et je vois apparaitre mon customcontrole dans la barre d'outil, donc je le rajoute sur ma fenêtre, et je lance l'execution histoire de voir s'il apparait bien ce textbox....
Et bien non! il n'apparait pas :'(
ça fait quelques dizaines de minutes que je cherche pourquoi et je ne trouve pas, je comprend pas pourquoi ça marche pas :/
Donc si vous pouviez m'aider svp :)
Merci !