mans
mans

Reputation: 18218

why this dockpanel doesn't work?

I have this xml:

 <DockPanel x:Name="TitleBar"  MouseDown="TitleBar_MouseDown" Background="Red">
        <Canvas DockPanel.Dock="Left">
            <Image Stretch="Fill" Width="295" Height="47" Source="/Resources\Images\TopPanel\Toplogo.png"/>
        </Canvas>
        <Canvas DockPanel.Dock="Right" Width="90">
            <Button Canvas.Left="70" DockPanel.Dock="Right" Width="16" Height="14" Style="{StaticResource TransparentButton}" Click="ButtonCloseWindowClick">
                <Image Height="14" VerticalAlignment="Top" >
                    <Image.Style>
                        <Style TargetType="{x:Type Image}">
                            <Setter Property="Source" Value="/Resources/Images/Toppanel/but_close.png"/>
                            <Style.Triggers>
                                <Trigger Property="IsMouseOver" Value="True">
                                    <Setter Property="Source"  Value="/Resources/Images/Toppanel/but_close_roll.png"/>
                                </Trigger>
                            </Style.Triggers>
                        </Style>
                    </Image.Style>
                </Image>
            </Button>
            <Image Canvas.Left="50" Stretch="Fill" Width="2" Height="33" Source="/Resources/Images/Toppanel/divider.png"/>
            <Button Canvas.Left="40" Width="16" Height="14" Style="{StaticResource TransparentButton}" Click="ButtonMinimizedClick" >
                <Image >
                    <Image.Style>
                        <Style TargetType="{x:Type Image}">
                            <Setter Property="Source" Value="/Resources/Images/Toppanel/but_minimise.png"/>
                            <Style.Triggers>
                                <Trigger Property="IsMouseOver" Value="True">
                                    <Setter Property="Source"  Value="/Resources/Images/TopPanel/but_minimise_roll.png"/>
                                </Trigger>
                            </Style.Triggers>
                        </Style>
                    </Image.Style>
                </Image>
            </Button>
            <Image  Canvas.Left="30"  Stretch="Fill" Width="2" Height="33" Source="/Resources/Images/Toppanel/divider.png"/>
            <Button   Canvas.Left="10" Canvas.Top="0"  Width="16" Height="14" Style="{StaticResource TransparentButton}" Click="ButtonInfoClick">
                <Image >
                    <Image.Style>
                        <Style TargetType="{x:Type Image}">
                            <Setter Property="Source" Value="/Resources/Images/Toppanel/but_info.png"/>
                            <Style.Triggers>
                                <Trigger Property="IsMouseOver" Value="True">
                                    <Setter Property="Source"  Value="/Resources/Images/TopPanel/but_info_roll.png"/>
                                </Trigger>
                            </Style.Triggers>
                        </Style>
                    </Image.Style>
                </Image>
            </Button>
            <Image  Canvas.Left="0" Canvas.Top="0"  Stretch="Fill" Width="2" Height="33" Source="/Resources/Images/Toppanel/divider.png"/>



        </Canvas>


    </DockPanel>

based on my understanding, the first canvas should be shown on the left and the other canvas should be shown on right hand size of window, but both of them shown on left hand size. Why dockpanel doesn't work?

Upvotes: 2

Views: 553

Answers (1)

dkozl
dkozl

Reputation: 33384

Since second Canvas is the last child of DockPanel and LastChildFill is true (default value):

If you set the LastChildFill property to true, which is the default setting, the last child element of a DockPanel always fills the remaining space, regardless of any other dock value that you set on the last child element.

Setting LastChildFill="False" against DockPanel

<DockPanel x:Name="TitleBar" ... LastChildFill="False">

should solve your problem

Upvotes: 2

Related Questions