WPF style par defaut ListView avec GridView dans generic.xaml
Bonjour,
Actuellement en cours de développement d'un Framework de CustomControls pour WPF, je suis tombé sur un problème que je n'arrive pas à résoudre.
J'ai une application bibliothèque de classe avec à l'intérieur une Class CustomListView.cs qui est un simple héritage de ListView pour le moment :
Code:
1 2 3 4 5 6 7 8
|
public class CustomListView : ListView
{
static CustomListView()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(CustomListView), new FrameworkPropertyMetadata(typeof(CustomListView)));
}
} |
Dans cette bibliothèque de classe, j'ai un fichier generic.xaml dans le dossier Themes contenant mon style par défaut pour mon contrôle CustomListView :
Code:
1 2 3 4 5
|
<Style TargetType="{x:Type local:CustomListView}">
<Setter Property="Background"
Value="Red" />
</Style> |
Ce fichier generic.xaml à les propriétés suivantes: Build Action = Page, et Custom Tool = MSBuild:Compile
Dans le fichier Assembly.cs, il y a :
Code:
1 2 3 4 5
|
[assembly:ThemeInfo(
ResourceDictionaryLocation.None,
ResourceDictionaryLocation.SourceAssembly
)] |
A coté, j'ai un projet WPF qui référence cette dll, ave une simple page qui affiche ma CustomListView.
Code:
1 2 3 4 5 6 7 8 9 10 11 12
|
<Window x:Class="TestCustomListView.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:cctrls="clr-namespace:WpfCustomControlLibrary1;assembly=WpfCustomControlLibrary1"
Title="MainWindow"
Height="350"
Width="525">
<Grid>
<cctrls:CustomListView />
</Grid>
</Window> |
Jusqu'ici, tout va bien, ma listView à un fond rouge.
Mon problème arrive lorsque je défini la "View" de ma CustomListView, la style n'est plus pris en compte.
Code:
1 2 3 4 5 6 7 8
|
<cctrls:CustomListView>
<cctrls:CustomListView.View>
<GridView>
<GridViewColumn />
</GridView>
</cctrls:CustomListView.View>
</cctrls:CustomListView> |
Y a t'il quelque chose à faire de particulier pour gérer les GridView dans mon style ?
De plus, encore plus étonnant pour moi, si je référence le fichier generic.xaml dans l'App.Xaml de mon application WPF, alors le style est bien utilisé :
Code:
1 2 3 4 5 6 7 8 9
|
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/WpfCustomControlLibrary1;component/Themes/Generic.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources> |
Mais je ne souhaite pas que l'application cliente référence le fichier generic.xaml de ma dll.
Avez vous une idée pour résoudre mon problème ?
Merci d'avance,