Hello,
Quelqu'un serait-il me dire comment faire de l'héritage avec des UserControl en WPF, car pour l'instant je galère un peu à trouver.
J'ai crée mon <<Master UserControl>> :
Mon code cs correspondant :Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 <UserControl x:Class="OpportuniteWpf.MasterUserCtrl" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Height="450" Width="550"> <Grid> <Button Height="23" Name="btRefresh" Width="95" HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="0,0,100,0"> <StackPanel Orientation="Horizontal"> <Image Source="/Images/icons/database_refresh.png" Width="16" Height="16" HorizontalAlignment="Left" Margin="0,0,5,0" /> <Label HorizontalAlignment="Center" Content="Rafraîchir"/> </StackPanel> </Button> <Button Height="23" Name="btSave" Width="95" HorizontalAlignment="Right" VerticalAlignment="Bottom"> <StackPanel Orientation="Horizontal"> <Image Source="/Images/icons/disk.png" Width="16" Height="16" HorizontalAlignment="Left" Margin="0,0,5,0" /> <Label HorizontalAlignment="Center" Content="Sauvegarder" /> </StackPanel> </Button> </Grid> </UserControl>
Ensuite J'ai crée mon UserControl qui devrait hériter de MasterUserCtrl :Code:
1
2
3
4
5
6
7
8 public partial class MasterUserCtrl : UserControl { public MasterUserCtrl() { InitializeComponent(); } }
Mon code cs correspondant :Code:
1
2
3
4
5
6
7
8
9
10
11 <local:MasterUserCtrl x:Class="OpportuniteWpf.UserCtrlContact" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:OpportuniteWpf" Height="400" Width="529" > <Grid> </Grid> </loacl:MasterUserCtrl>
Et quand je compile :Code:
1
2
3
4
5
6
7
8 public partial class UserCtrlContact : MasterUserCtrl { public UserCtrlContact() { InitializeComponent(); } }
Bref peut-être que je m'y prend pas correctement ?Citation:
Erreur 3 Erreur de génération inconnue, 'MC6017*: 'OpportuniteWpf.MasterUserCtrl' ne peut pas être la racine d'un fichier XAML, car sa définition a été faite à l'aide de XAML. Ligne 1 Position 23.' C:\Dev\OpportuniteWpf\OpportuniteWpf\UserCtrlContact.xaml 1 23 OpportuniteWpf
Quelqu'un aurait-il une petite idée sur la question ?
Merci d'avance.