Reputation: 1807
in a Visual Studio Extension Package I want to create a ToolWindow (like Solution Explorer is a ToolWindow) and use a ToolBar within this tool window (like Solution Explorer has it's own ToolBar with 'Show all Files' 'Refresh' and more).
If my ToolWindow is active tooltips are shown for the commands on the toolbar. They are not shown if any other tool window is active.
In Solution Explorer however, ToolTips are shown regardless of active the ToolWindow.
The same is true for clicking a toolbar item. A SolutionExplorer toolbar item can be clicked with one click even if solution explorer is not the active ToolWindow.
If my ToolWindow is not the active ToolWindow the first click activates my ToolWindow and only the second click clicks the button.
Does anyone know how to implement a behavior like Solution Explorers behavior in custom ToolWindows?
Thanks -M.
<UserControl x:Class="mklein.TestToolWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:vsfx="clr-namespace:Microsoft.VisualStudio.Shell;assembly=Microsoft.VisualStudio.Shell.10.0" mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300" Name="MyToolWindow"
Background="{DynamicResource {x:Static vsfx:VsBrushes.ToolWindowBackgroundKey}}" >
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<ToolBar Grid.Row="0" Background="{DynamicResource {x:Static vsfx:VsBrushes.CommandBarGradientKey}}">
<ToolBar.Items>
<Button Command="SaveAs" ToolTip="Save new">
<Image Source="resources\add.png" />
</Button>
<!-- ... -->
</ToolBar.Items>
</ToolBar>
<ListBox Grid.Row="1" x:Name="ListboxSettings"
ItemsSource="{Binding}"
IsSynchronizedWithCurrentItem="True"
MouseDoubleClick="ListBox_MouseDoubleClick">
</ListBox>
</Grid>
</UserControl>
Upvotes: 1
Views: 1708
Reputation: 6568
That's because you're creating a WPF toolbar, not a native Visual Studio toolbar (which is done via a VSCT file).
Take a look at this sample demonstrating how to host a 'native' toolbar with Visual Studio commands placed in it. This is the recommended way to create new commands or re-use existing commands within Visual Studio in your toolwindow. This also allows the user to customize the commands and specify their own keybindings.
Upvotes: 2