I am writing a ControlTemplate toolbar for toolbars that uses UniformGrid to provide multiple columns for toolbar elements. It still seems that even with the default default ControlTemplate layout (a la MSDN Documentation ), overflow in ToolBarOverflowPanel no longer works. I tried to use both the standard tool ToolBarOverflowPanel and the StackPanel in no case; the corresponding snippit template can be found here .
How do I get Overflow to work correctly?
Also, when placing the ToolBar inside the ToolBarTray, how can I detect and set the "Thumb", "Content" and "Overflow Toggle Button" to their correct positions? The documentation for ToolBar ControlTemplates does not seem to cover this.
edit . I also wonder how I can bind the UniformGrid Column property in the main xaml window?
edit 2 . Got the basic ToolBarTray orientation solution, you just need to add ControlTemplate triggers for related related properties (Trigger Property = "ToolBarTray.Orientation" Value = "Vertical"). Also, who seriously gives due written question?
<ToggleButton DockPanel.Dock="Right"
ClickMode="Press"
IsChecked="{Binding
IsOverflowOpen,
Mode=TwoWay,
RelativeSource={RelativeSource TemplatedParent}
}"
IsEnabled="{TemplateBinding HasOverflowItems}"
>
<ToggleButton.Template>
<ControlTemplate TargetType="{x:Type ToggleButton}">
<Border x:Name="Border"
Background="{StaticResource
{x:Static SystemColors.MenuBarBrushKey}
}"
CornerRadius="0,3,3,0"
SnapsToDevicePixels="true"
>
<Grid>
<Path x:Name="Arrow"
Data="M -0.5 3 L 5.5 3 L 2.5 6 Z"
Fill="{StaticResource {x:Static
SystemColors.ControlTextBrushKey
}}"
Margin="2,3"
VerticalAlignment="Bottom"
/>
<ContentPresenter />
</Grid>
</Border>
</ControlTemplate>
</ToggleButton.Template>
<Popup x:Name="OverflowPopup"
AllowsTransparency="true"
Focusable="false"
IsOpen="{Binding
IsOverflowOpen,
RelativeSource={RelativeSource TemplatedParent}
}"
Placement="Bottom"
PopupAnimation="Slide"
StaysOpen="false"
>
<Border x:Name="DropDownBorder"
Background="{StaticResource
{x:Static SystemColors.MenuBarBrushKey}
}"
BorderBrush="{StaticResource
{x:Static SystemColors.ControlDarkBrushKey}
}"
BorderThickness="1"
>
<StackPanel x:Name="PART_ToolBarOverflowPanel"
Focusable="true"
FocusVisualStyle="{x:Null}"
KeyboardNavigation.TabNavigation="Cycle"
KeyboardNavigation.DirectionalNavigation="Cycle"
Margin="2"
/>
</Border>
</Popup>
</ToggleButton>
source
share