I continued to read my extension tutorial a bit . When you look at the sample code for this project, the code below should be clear.
The first method below is called when the active document is modified. This method handles the ActiveDocumentChanged IDocumentService event . First, it gets the contents of the TimelinePane from the registry palette. This content contains the ActiveSceneViewModel . ActiveSceneViewModel is a viewmodel that contains the active scene (= current xaml file, editable). ActiveSceneViewModel contains a set of selected items, ElementSelectionSet. You have an event (Changed) that fires when it changes. Handle this event.
In this event handler, you will have access to the selection set immediately after changing it.
private void ActiveDocumentChanged(object sender, DocumentChangedEventArgs e)
{
var timelinePane =
(TimelinePane)WindowService.PaletteRegistry["Designer_TimelinePane"].Content;
_activeSceneViewModel = timelinePane.ActiveSceneViewModel;
_activeSceneViewModel.ElementSelectionSet.Changed +=
new System.EventHandler(ElementSelectionSet_Changed);
}
void ElementSelectionSet_Changed(object sender, System.EventArgs e)
{
SceneElementSelectionSet selectionSet
= sender as SceneElementSelectionSet;
}
source
share