Hi all,
I am currently working on a VS extension that entails the application of various modifications to a XAML element (such as a Control or a Panel) being selected in XAML Designer. Therefore, I require to determine the selected element´s position within the underlying XAML source code.
As long as both XAML Designer and XAML Code editor are open (XAML Designer split screen), this works. The user may select the required source code section manually or, alternatively, select an element in the designer which subsequently auto-triggers an update of the selection in the source code view. Unfortunately, if only XAML Designer is open (and Code editor closed), I don´t get a proper selection index as VS (understandably) does not trigger any selection updates to the underlying XAML code if there is currently no markup view open.
So, in a nutshell, my humble question is: How can I retrieve the source code index of a XAML element which has been selected in XAML designer while source code view is closed?
My first approach was to manually execute the View.ViewDesigner command which is basically responsible for just this operation: opening the XAML code editor from XAML designer in split screen mode and selecting the selected element´s source. While using this command via keyboard shortcut or Command Window works like a charm, it doesn´t work similarly when being executed via DTE.ExecuteCommand method: although the underlying XAML code is being opened, there is a) no selection and b) no split screen (instead, the designer view is being closed completely).
Any help is much appreciated!
Cheers,
Philip