File tree Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Original file line number Diff line number Diff line change 11using System ;
22using System . Threading . Tasks ;
3+ using System . Windows . Controls ;
34using Microsoft . VisualStudio . Shell ;
45using Microsoft . VisualStudio . Shell . Interop ;
56
@@ -17,7 +18,7 @@ public class InfoBarFactory
1718 public async Task < InfoBar ? > CreateAsync ( InfoBarModel model )
1819 {
1920 await ThreadHelper . JoinableTaskFactory . SwitchToMainThreadAsync ( ) ;
20-
21+
2122 IVsShell shell = await VS . Services . GetShellAsync ( ) ;
2223 shell . GetProperty ( ( int ) __VSSPROPID7 . VSSPROPID_MainWindowInfoBarHost , out object value ) ;
2324
@@ -129,6 +130,24 @@ public async Task<bool> TryShowInfoBarUIAsync()
129130 return IsVisible ;
130131 }
131132
133+ /// <summary>
134+ /// Attempts to get the underlying WPF UI element of the InfoBar
135+ /// </summary>
136+ public bool TryGetWpfElement ( out Control ? control )
137+ {
138+ object ? uiObject = null ;
139+ control = null ;
140+ _uiElement ? . GetUIObject ( out uiObject ) ;
141+
142+ if ( uiObject is IVsUIWpfElement elm )
143+ {
144+ elm . GetFrameworkElement ( out object frameworkElement ) ;
145+ control = frameworkElement as Control ;
146+ }
147+
148+ return control != null ;
149+ }
150+
132151 /// <summary>
133152 /// Closes the InfoBar without the user manually had to do it.
134153 /// </summary>
You can’t perform that action at this time.
0 commit comments