Est-ce que quelqu'un sait de la raison pour laquelle "" n'a pas pu créer l'instance de UserControl "" erreur peut se produire. Il me semble que cela se produit de façon complètement spontanée, par exemple après avoir ajouté de l'espace après le nœud ou changé la tabulation. Peut-être que c'est une sorte de bug VS?Erreurs WPF étranges dans Visual Studio
Voici les contrôles. Cette configuration génère en fait une erreur
<UserControl x:Class="ShortcutsPrototype.KeyboardShortcutsTreePanel"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:ShortcutsPrototype="clr-namespace:ShortcutsPrototype">
<Grid Margin="3,3,3,3">
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition Width="80" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition Height="30" />
</Grid.RowDefinitions>
<ShortcutsPrototype:KeyboardShortcutsTreeView />
<Button Grid.Row="1" Margin="3,3,3,3" Grid.Column="1" HorizontalAlignment="Stretch">Reset</Button>
</Grid>
</UserControl>
<UserControl x:Class="ShortcutsPrototype.KeyboardShortcutsTreeView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:ShortcutsPrototype="clr-namespace:ShortcutsPrototype"
Height="300" Width="300">
<Grid>
<TreeView>
<TreeViewItem HorizontalContentAlignment="Stretch">
<TreeViewItem.Header>
<ShortcutsPrototype:KeyboardShortcutsTreeViewEntry x:Name="generalTreeViewEntry" Title="General" />
</TreeViewItem.Header>
<TreeViewItem HorizontalContentAlignment="Stretch">
<TreeViewItem.Header>
<ShortcutsPrototype:KeyboardShortcutsTreeViewEntry x:Name="generalNewFileTreeViewEntry" Title="New File" ShortcutKey="Ctrl+N" />
</TreeViewItem.Header>
</TreeViewItem>
<TreeViewItem HorizontalContentAlignment="Stretch">
<TreeViewItem.Header>
<ShortcutsPrototype:KeyboardShortcutsTreeViewEntry x:Name="generalOpenFileTreeViewEntry" Title="Open File" ShortcutKey="Ctrl+O" />
</TreeViewItem.Header>
</TreeViewItem>
<TreeViewItem HorizontalContentAlignment="Stretch">
<TreeViewItem.Header>
<ShortcutsPrototype:KeyboardShortcutsTreeViewEntry x:Name="generalSaveFileTreeViewEntry" Title="Save File" ShortcutKey="Ctrl+S" />
</TreeViewItem.Header>
</TreeViewItem>
<TreeViewItem HorizontalContentAlignment="Stretch">
<TreeViewItem.Header>
<ShortcutsPrototype:KeyboardShortcutsTreeViewEntry x:Name="generalSaveAsFileTreeViewEntry" Title="Save File As.." ShortcutKey="Ctrl+Shift+S" />
</TreeViewItem.Header>
</TreeViewItem>
</TreeViewItem>
<TreeViewItem HorizontalContentAlignment="Stretch">
<TreeViewItem.Header>
<ShortcutsPrototype:KeyboardShortcutsTreeViewEntry x:Name="debugerTreeViewEntry" Title="Debuger" />
</TreeViewItem.Header>
</TreeViewItem>
<TreeViewItem HorizontalContentAlignment="Stretch">
<TreeViewItem.Header>
<ShortcutsPrototype:KeyboardShortcutsTreeViewEntry x:Name="refactoringTreeViewEntry" Title="Refactoring" />
</TreeViewItem.Header>
</TreeViewItem>
</TreeView>
</Grid>
</UserControl>
<UserControl x:Class="ShortcutsPrototype.KeyboardShortcutsTreeViewEntry"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Height="25">
<Grid>
<Grid.RowDefinitions>
<RowDefinition />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition Width="100" />
</Grid.ColumnDefinitions>
<Label x:Name="titleLabel" Grid.Column="0"></Label>
<Label x:Name="shortcutLabel" Grid.Column="1"></Label>
</Grid>
</UserControl>
Hm, vous avez probablement raison. Je croyais en ReSharper et jeté l'extension de la classe UserControl dans le code derrière. Après l'avoir lu, cela a de nouveau fonctionné sans problèmes –