Click here to Skip to main content
13,446,550 members (33,108 online)
Rate this:
Please Sign up or sign in to vote.
See more:
WPF GridSplitter and browser control doesn't work as expected. when I move the GridSplitter the content spills out of window. This happens when you give default width to the browser control. Any idea how to fix this?

Sample code
<Window x:Class="htmlBrowserControl.MainWindow"



        Title="MainWindow" Height="350" Width="525">
    <Grid removed="AliceBlue">
            <ColumnDefinition />
            <ColumnDefinition Width="500"/>
        <GridSplitter Grid.Column="1" Width="5" ></GridSplitter>
        <!--<Grid Grid.Column="2">-->
        <WebBrowser Grid.Column="2" Source="C:\HelpConfig\PSCHelp.html" Width="500" ></WebBrowser>
Posted 23-Jan-14 21:18pm
Updated 16-Oct-17 0:55am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

You're not giving it the default width. You're giving it the width. That's why it's getting pushed out. The GridSplitter controls the width of the cell that it's in. I think your XAML is wrong in that regard, because you have it in it's own cell.

You can define some constraints by specifying MinWidth values. WPF frowns on hardcoding height and width values. Here's what I think you want.

<window x:class="CpGridSplitter.MainWindow"



        Title="MainWindow" Height="350" Width="550" MinWidth="550">
            <columndefinition width="Auto" minwidth="50" />
            <columndefinition minwidth="500" />
        <button grid.column="0" content="Foo" />
        <gridsplitter grid.column="0" width="5" />
        <webbrowser grid.column="1" source="" />

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web04 | 2.8.180314.2 | Last Updated 16 Oct 2017
Copyright © CodeProject, 1999-2018
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100