UIItem for GridSplitter

Sep 14, 2010 at 10:14 PM

What is the right UIItem for WPF GridSplitter and how can I simulate a drag?

Sep 15, 2010 at 12:03 AM
Edited Sep 15, 2010 at 12:03 AM

It seems that it should be Thumb. This is what I have so far:

var t = w.Get<Thumb>("splitter");
Assert.IsNotNull(t);
t.SlideHorizontally(-100);

I am assuming that since t is not null, I actually did find the correct item and that Thumb is the correct type for it. But doing the SlideHorizontal does not yield the desired result. Instead a different (adjacent) button gets clicked. This is ym Testwindow:

 

<Window x:Class="WhiteTest.ApplicationUnderTest.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="WindowUnderTest" Height="350" Width="525">
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="262*" />
            <ColumnDefinition Width="241*" />
        </Grid.ColumnDefinitions>
        <Button AutomationProperties.AutomationId="buttonOne" Click="ButtonOneOnClick">Click me!</Button>
        <GridSplitter AutomationProperties.AutomationId="splitter" HorizontalAlignment="Right" Width="10"></GridSplitter>
        <Button AutomationProperties.AutomationId="buttonTwo" Click="ButtonTwoOnClick" Grid.Column="1">Click me too!</Button>
    </Grid>
</Window>