WPF toolbar disappearing on resize

Posted by user1122909 on Stack Overflow See other posts from Stack Overflow or by user1122909
Published on 2012-12-13T17:02:19Z Indexed on 2012/12/13 17:03 UTC
Read the original article Hit count: 431

Filed under:
|
|

On my main form I have a toolbar with a number of buttons. Once the parent form is resized down by dragging it so that the entire toolbar with all its buttons no longer fits in the width of the window, the whole toolbar disappears.

Is there a way I can make it so that as you resize it, when you get to the width of the toolbar the inner controls of the form stop resizing and stay displayed, just cut off where the window has resized to?

Code is

<Grid >
<Grid.RowDefinitions>
    <RowDefinition Height="Auto" />
    <RowDefinition Height="Auto" />
    <RowDefinition Height="*" />
        <RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
    <ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
    <ToolBar Grid.Row="1" Height="50" Name="tbMainToolbar" VerticalAlignment="Top" MinWidth="900" >
    <ToolBar.Background>
        <LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1">
            <GradientStop Color="White" Offset="0.0" />
            <GradientStop Color="#DCEBFF" Offset="0.25" />
            <GradientStop Color="#99CCFF" Offset="0.75" />
            <GradientStop Color="#99CCFF" Offset="1.0" />
            </LinearGradientBrush>
    </ToolBar.Background>
    <DockPanel LastChildFill="True">
        <Button Name="btnApproved" DockPanel.Dock="Left" Click="btnToolbar_Click" CommandParameter="APPROVED"
                Style="{StaticResource ToolbarButtonDisplay}" HelperClasses:ButtonProperties.Image="..\..\Resources\Images\APPROVEU.GIF" Content="Approve">
        </Button>
        ... and so forth for about 20 buttons

© Stack Overflow or respective owner

Related posts about c#

Related posts about wpf