Sorry for a very specific question, bot why VS2008 and VS2010 crashes with this code? I though it's a common to use ObjectDataProvider to bind property. I seen examples in many places on the web, but werether I try to use it I get exception and my VS closes.
So, what is wrong with my code? Should I register a bug for VS?
<Window x:Class="ShortcutsManagementAddin.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:ShortcutsManagementAddin"
Title="Window1" Height="300" Width="300">
<Window.Resources>
<ObjectDataProvider x:Key="Window1" ObjectType="{x:Type local:Window1}" />
</Window.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="30" />
<RowDefinition Height="*" />
<RowDefinition Height="30" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="30" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="30" />
</Grid.ColumnDefinitions>
<TreeView ItemsSource="{Binding Source={StaticResource Window1}, Path=Categories}"></TreeView>
</Grid>
</Window>
namespace ShortcutsManagementAddin
{
public class Shortcut
{
public string CategoryName;
}
/// <summary>
/// Interaction logic for Window1.xaml
/// </summary>
public partial class Window1 : Window
{
private List<Shortcut> categories = new List<Shortcut>();
public List<Shortcut> Categories
{
get { return categories; }
}
public Window1()
{
categories.Add(new Shortcut { CategoryName = "Category 1" });
categories.Add(new Shortcut { CategoryName = "Category 2" });
categories.Add(new Shortcut { CategoryName = "Category 3" });
categories.Add(new Shortcut { CategoryName = "Category 4" });
categories.Add(new Shortcut { CategoryName = "Category 5" });
InitializeComponent();
}
}
}