views:

7

answers:

0

I have a TreeView wich has many types of items but they all inherit from a base class. Besides the TreeView there is a MasterDetail view for the selected item.

Below the MasterDetail view I wan't to have a edit button that changes the MasterDetail view into edit view.

I'm doing this by having the master detail view as a ContentPresenter with the selectedItem from the treeview as content.

ContentPresenter Content="{Binding ElementName=CompanyTree, Path=SelectedItem}">

Then I have DataTemplates for the different types. Now the DataTemplate calls on a ViewTemplate for the type if the item is not in edit mode else calls on the editTemplate.

That's all good but my idea was to put a edit button on the bottom of the ViewTemplates and Cancel adn Save button on the EditTemplate. However I can't seem to put eventbuttons in a resourcedictionary.

So I'm not sure how to do this. I thought I could put it below the ContentPresenter and hide them based on wether I'm in editMode or not but that has several problems.

The ContentPresenter doesn't assume type so he can't assume the SelectedItem has the IsInEditMode property. Also when You first fire up the masterDetail window is empty but still has the Edit button. How can I check if there is any selected item?

So what's the best solution for this problem?