Question

I have a DockPanel with two Grids (DockPanel.Dock="Right/Left"). In the left i have a TreeView and in the right i have some TextBoxes. If i resize my window the panels resize proportinal.

My problem is, if i write long text in a TextBox the TextBox enlarge and hide my left DockPanel instead of a break the text.

I have set minwidth of the left DockPanel to '300' and set TextWrapping in the TextBoxes to 'wrap' but nothing helps.

Source:

 <Grid Background="#FF58ACFC" Name="main">
    <DockPanel>
       <Grid DockPanel.Dock="Right" Margin="0,0,5,0">

            <Grid.ColumnDefinitions>
                <ColumnDefinition MinWidth="200" />                    
            </Grid.ColumnDefinitions>

            <Grid.RowDefinitions>
                <RowDefinition Height="26"/>
                <RowDefinition Height="26"/>
                <RowDefinition Height="26"/>
                <RowDefinition Height="60" />
                <RowDefinition Height="26"/>
                <RowDefinition />
            </Grid.RowDefinitions>

            <Label Content="Titel:" Grid.Row="0"/>
            <TextBox Grid.Row="1" IsReadOnly="False">

            <Label Content="Frage:" Grid.Row="2"/>
            <TextBox Grid.Row="3" TextWrapping="Wrap" IsReadOnly="False" AcceptsReturn="True">

            <Label Content="Antwort:" Grid.Row="4"/>
            <TextBox Grid.Row="5" IsReadOnly="False" TextWrapping="Wrap" />
        </Grid>


        <Grid DockPanel.Dock="Left" Margin="5,0,0,0">

            <DockPanel>
                <Grid DockPanel.Dock="Left">
                    <DockPanel LastChildFill="True">
                        <Grid DockPanel.Dock="Top" Height="26">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition />
                                <ColumnDefinition />
                            </Grid.ColumnDefinitions>
                            <Label Content="Kategorie" Grid.Column="0"/>
                            <Button Grid.Column="1" BorderThickness="0" HorizontalAlignment="Right">
                        </Grid>

                        <TreeView HorizontalAlignment="Stretch" VerticalAlignment="Stretch"Padding="0,0,15,0" />
                    </DockPanel>
                </Grid>

                <Grid DockPanel.Dock="Right">
                    <DockPanel LastChildFill="True">

                        <Grid DockPanel.Dock="Top" Height="26">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition />
                                <ColumnDefinition />
                            </Grid.ColumnDefinitions>

                            <Label Content="Lernkarten" Grid.Column="0"/>
                            <Button Grid.Column="1" Width="26" Click="ButtonAddItem_Click">
                        </Grid>

                        <ListView />
                    </DockPanel>
                </Grid>
            </DockPanel>
        </Grid>
    </DockPanel>
</Grid>
Was it helpful?

Solution

That's pretty much why Dockpanels are useless :-)

I suggest using Grid..

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top