Does anybody know of the reason why ”could not create instance of UserControl” error can occur. It seems to me that it occurs completely spontanous, for example after I add space after node or change tabulation. Maybe it’s some kind of VS bug?
Here are controls. This configuration actually raises an error
<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>
Perhaps something in your CodeBehind file is throwing an exception. Have you checked that?