Khonan
Topic Author
Posts: 24
Joined: 23 Jan 2019, 10:18

Load a Xaml and set as DockPanel's child

28 Feb 2019, 11:35

Hi,

I'm experiencing a strange behavior :

Having a DockPanel with 3 buttons dock to top :
<Grid Grid.Column="2" HorizontalAlignment="Left" VerticalAlignment="Top">
                <ScrollViewer>
                    <Border BorderBrush="Black" BorderThickness="4">
                    <DockPanel x:Name="itGridViewRight" VerticalAlignment="Top">
                            <Button DockPanel.Dock="Top" Margin=" 0,0,0,0">TOTO</Button>
                            <Button DockPanel.Dock="Top" Margin=" 0,0,0,0">TOTO</Button>
                            <Button DockPanel.Dock="Top" Margin=" 0,0,0,0">TOTO</Button>
                        </DockPanel>
                    </Border>
                </ScrollViewer>
            </Grid>
            
If I load the following XAML and set as DockPanel's children:
<Grid DockPanel.Dock="Top" VerticalAlignment="Top" Height="50"
    x:Class="Atome2.FileListDock"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Background="#FF1A1A1D" >

    <Button >TITI</Button>
</Grid>
The loaded button is always misplaced in the DockPanel... Same result with a stackpanel...
Attachments
Capture.PNG

Tags:
 
Khonan
Topic Author
Posts: 24
Joined: 23 Jan 2019, 10:18

Re: Load a Xaml and set as DockPanel's child

28 Feb 2019, 12:00

I tried after the "parent.Children.Add(control);" to do a parent.UpdateLayout(); or even a parent.InvalidateMeasure(); but with no success..
 
Khonan
Topic Author
Posts: 24
Joined: 23 Jan 2019, 10:18

Re: Load a Xaml and set as DockPanel's child

28 Feb 2019, 15:57

Found the origin of the problem.

My class is not directly a UserControl but instead my own class wich inherit from UserControl... My own class was performing a Center() on the window at init... My Bad so... and not Noesis's Fault ;)


Fixed. :)
 
User avatar
sfernandez
Site Admin
Posts: 1915
Joined: 22 Dec 2011, 19:20

Re: Load a Xaml and set as DockPanel's child

28 Feb 2019, 16:40

Thanks for the update.

Who is online

Users browsing this forum: No registered users and 1 guest