Salut,
Dans un projet j'ai besoin de faire de l'héritage sur le control combobox. Je souhaite définir un template dans cet héritage, mais je n'y arrive pas
Voici le XAML de mon control DropDOwnCustomControl
Code xml : 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 <ComboBox x:Class="MyCustomControl.DropDownCustomControl" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" > <ComboBox.ItemTemplate> <DataTemplate> <StackPanel Margin="0,3,0,3"> <StackPanel Orientation="Horizontal"> <TextBlock Width="150" Text="{Binding Path=NameValue}" VerticalAlignment="Center" FontSize="14"/> <TextBlock Text="{Binding Path=CodeValue}" HorizontalAlignment="Right" VerticalAlignment="Center" FontSize="12" /> </StackPanel> </StackPanel> </DataTemplate> </ComboBox.ItemTemplate> </ComboBox>
Le template n'est pas pris en compte... Par contre si je met le template lorsque j'utilise cette nouvelle classe elle est bien pris en compte... ex:
Code xml : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12 <bap:DropDownCustomControl Name="DropDownCustomControl1"> <ComboBox.ItemTemplate> <DataTemplate> <StackPanel Margin="0,3,0,3"> <StackPanel Orientation="Horizontal"> <TextBlock Width="150" Text="{Binding Path=NameValue}" VerticalAlignment="Center" FontSize="14"/> <TextBlock Text="{Binding Path=CodeValue}" HorizontalAlignment="Right" VerticalAlignment="Center" FontSize="12" /> </StackPanel> </StackPanel> </DataTemplate> </ComboBox.ItemTemplate> </bap:DropDownCustomControl>
Avez vous une idée de pourquoi, et donc de comment résoudre ce problème?
Merci d'avance !!
Partager