I have a TreeView, and I want to be able to add children to it and to the Linq to SQL database that it's bound to.
The best way that I can think of (off the top of my head) would be to have the user right click on a parent node and have the option to add new item from a context menu.
I added a context menu, but when I try to program it in the back end, it says that there is no event handler associated with it.
<TreeView Name="TreeView1" Margin="3" ItemsSource="{Binding ElementName=ManufacturerWarranty, Path=ManufacturerQuery, UpdateSourceTrigger=PropertyChanged}">
<TreeView.ItemTemplate>
<HierarchicalDataTemplate ItemsSource="{Binding Path=WarrantyList}">
<TextBlock Name="txtManufacturerName" Text="{Binding Path=ManufacturerName}">
<TextBlock.ContextMenu>
<ContextMenu>
<MenuItem Name="mnuAddRecord" Header="Add Year Record"></MenuItem>
</ContextMenu>
</TextBlock.ContextMenu>
</TextBlock>
<HierarchicalDataTemplate.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Path=Years}">
<TextBlock.ContextMenu>
<ContextMenu>
<MenuItem Name="mnuDelRecord" Header="Remove Year Record"></MenuItem>
</ContextMenu>
</TextBlock.ContextMenu>
</TextBlock>
</DataTemplate>
</HierarchicalDataTemplate.ItemTemplate>
</HierarchicalDataTemplate>
</TreeView.ItemTemplate>
</TreeView>
Whats the correct way to do this?