0
votes

I am working in a WPF application. And my problem is regarding the GridSplitter visiblity.

In my xaml code,I am maitaining a Grid. In the 3rd row of Grid, I am hosting a Winform DataGridView. In the same row, the GridSplitter is written.

When GridSplitter is dragged to adjust Grid Row sizes, for other controls like Buttons etc it is properly visible. But when it comes over the DataGridView which I am hosting, the GridSplitter hides behind the hosted control.

In fact, whatever I host instead of Datagridview,makes the GridSplitter hide behind it, when it is dragged.

I tried setting the ZIndex for GridSplitter. It did not make any difference.

Can anyone help me with this?

Following is my XAML sample code:-

<Grid>
    <Grid.RowDefinitions>
        <RowDefinition Name="rowForButton"/>
        <RowDefinition Name="rowForGridSplitter" Height="Auto" MinHeight="81" />
    </Grid.RowDefinitions>
    <Button Grid.Row="0" Height="50" Width="110" Content="Button in First Row"/>
    <my:WindowsFormsHost Panel.ZIndex="0" Grid.Row="1"  Margin="30,11,138,0" x:Name="winHost" Height="58" VerticalAlignment="Top" OpacityMask="Transparent">            
        <win:DataGridView x:Name="dataGridView"></win:DataGridView>
    </my:WindowsFormsHost>        
    <GridSplitter  BorderThickness="1" Panel.ZIndex="1" Grid.Row="1" HorizontalAlignment="Stretch" Height="5" ShowsPreview="True" VerticalAlignment="Top">
    </GridSplitter>
</Grid>

Thanks.

2
Duplicate of stackoverflow.com/questions/720375/wpf-gridsplitter-visiblity. You know that you can edit your questions and add information to it?Joey
I was not able to do the same because of some problem. Sorry for that. :(Prachi

2 Answers

0
votes

Unfortuantely the WinForms control will always sit on top of your WPF elements, it does the same when you try and scroll it. The best way to work around it is to put the required logic for sizing/scrolling/whatever the WinForms part into a WinForms control, then host that control in the WPF form.

0
votes

Your Grid has only 2 rowdefinitions but needs 3. At the moment the WindowsFormsHost and the GridSplitter are sharing the second row (i.e. Grid.Row="1"). Presumably you want the WindowsFormsHost to use Grid.Row="2".