Bonjour à tous,
voila j'essaye de créer un UserControl. J'ai donc créé la partie XAML que je souhaite rattacher a mon code CS
et derriére j'ai mon code C#
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 <UserControl x:Class="WPF_Test1.MyButton" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" > <UserControl.Resources> <ControlTemplate TargetType="{x:Type local:MyButton}" x:Key="MyButtonTemplate"> <Grid> <Image Source="{TemplateBinding ButtonBackground}" /> </Grid> </ControlTemplate> </UserControl.Resources> <Grid> <Grid x:Name="grd"> <Button Template="MyButtonTemplate"></Button> </Grid> </Grid> </UserControl>
l'erreur se situe sur cette ligne :
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
21 public partial class MyButton : System.Windows.Controls.UserControl { private Image mBackground; public Image ButtonBackground { get { return mBackground; } set { mBackground = value; } } private Label mLabel; public Label ButtonLabel { get { return mLabel; } set { mLabel = value; } } static MyButton() { InitializeComponent(); } }
il me dit qu'il ne reconnait pas le mot clef local
Code : Sélectionner tout - Visualiser dans une fenêtre à part TargetType="{x:Type local:MyButton}
comment se fait il ?
merci d'avance pour votre aide
Partager