Click here to Skip to main content
15,912,400 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi:

I am looking for a slider or panel slider in WPF.

I have tried using the GridSplitter, but I'm not getting the behaviour that I want.
The grid's content get's overlayed and does not get displayed correctly.

Depending on config settings, I need to be able to hide/show the splitter and one of the panels at app startup/load time.

I know there was a SplitPanel available in Winforms.
There doesn't seem to be such a entity in WPF.
Does anyone have any suggestions?

I've attached a graphic indicating what I'm looking for.
This what my XAML currently looks like:

XML
<Window x:Class="Facility.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:rpiRTFControl="clr-namespace:ReportingFacilityControlLibrary;assembly=ReportingFacilityControlLibrary"
        Title="Facility"  WindowStartupLocation="CenterScreen" WindowStyle="ToolWindow"  ResizeMode="CanResize"  WindowState="Maximized" Loaded="Window_Loaded">

    <Grid  removed="#7A66BAD2">
        <Grid.RowDefinitions>
            <RowDefinition Height="9*"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height=".05*"/>
        </Grid.RowDefinitions>

        <Grid  Grid.Row="0" removed="#7A66BAD2">
            <Grid.RowDefinitions>
                <RowDefinition Height="9*"/>
                <RowDefinition Height="1*"/>
            </Grid.RowDefinitions>

            <StackPanel Grid.Row="0" >
                
                <WindowsFormsHost Name="RPIWinformsHost" Height="700"
                                  removed="Orange" 
                                  HorizontalAlignment="Stretch" 
                                  VerticalAlignment="Stretch"
                                  Margin="30,10,30,10">
                    <rpiRTFControl:UserControl Name="RPIRTFControl" />

                </WindowsFormsHost>
                
            </StackPanel>

            <Border BorderBrush="#CCCCFF" Grid.Row="1" BorderThickness="6" 
                    HorizontalAlignment="Stretch" Margin="30,0,30,0">
                <StackPanel Name="spCommands" 
                    Orientation="Horizontal">

                    <Button Name="btnRevert" Content="Revert" Height="25" Width="134"                                            
                FontSize="13" FontWeight="Bold" 
                Margin="30,0,10,0"
                Click="btnRevert_Click" />

                    <Button Name="btnTest" Content="Test" Height="25" Width="134"                                            
                FontSize="13" FontWeight="Bold" 
                Margin="10,0,10,0"
                Click="btnTest_Click" />

                    <Button Name="btnEdit" Content="Edit" Height="25" Width="134"                                            
                FontSize="13" FontWeight="Bold" 
                Margin="10,0,10,0"
                Click="btnEdit_Click" />

                    <Button Name="btnUpdate" Content="Update" Height="25" Width="134"                                            
                FontSize="13" FontWeight="Bold" 
                Margin="10,0,10,0"
                Click="btnUpdate_Click" />

                    <Button Name="btnClose" Content="Close" Height="25" Width="134"                                            
                FontSize="13" FontWeight="Bold" 
                Margin="10,0,30,0"
                Click="btnRevert_Click" />

                </StackPanel>
            </Border>

        </Grid>

        <GridSplitter Name="DebugSplitter" Grid.Row="1"
                      Height="5"
                      removed="Red"
                      HorizontalAlignment="Stretch"
                      VerticalAlignment="Center"
                      ResizeBehavior="BasedOnAlignment"/>
        
        <StackPanel Name="DebugPanel" Grid.Row="2">
            <Border BorderBrush="#CCCCFF" BorderThickness="6" HorizontalAlignment="Stretch" Padding="20" Margin="20,10,20,20">

                <TabControl Name="Tabs1" TabStripPlacement="Top" removed="Coral" BorderBrush="Blue" BorderThickness="4" Margin="5, 5, 5, 5" 
                        VerticalAlignment="Stretch" HorizontalAlignment="Stretch">

                    <TabItem Header="SMS Testing Panel" IsSelected="True" removed="LightCoral">

                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition />
                                <RowDefinition />
                                <RowDefinition />
                                <RowDefinition />
                            </Grid.RowDefinitions>

                            <Grid.ColumnDefinitions>
                                <ColumnDefinition />
                            </Grid.ColumnDefinitions>

                            <StackPanel  Orientation="Horizontal" HorizontalAlignment="Stretch" Grid.Column="0" Grid.Row="0"></StackPanel>

                            <StackPanel  Orientation="Horizontal" HorizontalAlignment="Stretch" Grid.Column="0" Grid.Row="1">

                                <Label Content="Notification" FontFamily="Trebuchet MS" FontSize="12" FontWeight="Bold" Height="28" 
                                HorizontalAlignment="Center" Margin="30,10,20,0" Name="label4" VerticalAlignment="Center" Width="81" Foreground="#FF1A1A17" />

                                <Label FontFamily="Trebuchet MS" FontWeight="Bold" Height="25" HorizontalAlignment="Center" Margin="20,10,68,0" Name="lblNotfication" 
                                    VerticalAlignment="Center" VerticalContentAlignment="Center" Width="479" Foreground="#FF112705" Background="LemonChiffon"/>
                            </StackPanel>

                            <StackPanel  Orientation="Vertical" HorizontalAlignment="Stretch" Grid.Column="0" Grid.Row="2">

                                <Label Content="Component State" FontWeight="Bold" Height="34" HorizontalAlignment="Left" Margin="30,10,10,0" Name="label3" 
                                    VerticalAlignment="Center" Width="125" Foreground="#FF1A1A17"/>

                                <TextBox AcceptsReturn="True" HorizontalAlignment="Left" Margin="30,0,20,10" 
                                        Name="txtSMSResults" TextWrapping="Wrap" VerticalAlignment="Center" Width="600" Height="100" removed="LemonChiffon"/>
                            </StackPanel>

                            <StackPanel  Orientation="Vertical" HorizontalAlignment="Stretch" Grid.Column="0" Grid.Row="3">
                                <StackPanel Orientation="Horizontal">
                                    <Button Content="Restart" Height="23" HorizontalAlignment="Center"  VerticalAlignment="Center"  
                                        Name="button2" FontFamily="Trebuchet MS" FontWeight="Bold"  Width="75" Click="btnRestart_Click" Margin="20,10,30,10"/>
                                    
                                    <Label Content="Case Status" Height="23" Name="label1" Width="82" FontWeight="Bold" Foreground="#FF1A1A17" />
                                    
                                    <CheckBox Content="ON/OFF" Height="16" Name="checkBox1" FontWeight="Bold" Foreground="#FF1A1A17" />
                                    
                                    <Button Content="Send Case Status" Height="25" Name="publishStatus" Width="134" Click="publishStatus_Click" 
                                            FontSize="13" FontStyle="Italic" FontWeight="Bold" />
                                    
                                </StackPanel>
                            </StackPanel>
                        </Grid>
                    </TabItem>

                    <TabItem Header="Reporting Interface Testing Panel" removed="LightCoral">

                        <Grid>

                            <Grid.RowDefinitions>
                                <RowDefinition />
                                <RowDefinition />
                                <RowDefinition />
                                <RowDefinition />
                            </Grid.RowDefinitions>

                            <Grid.ColumnDefinitions>
                                <ColumnDefinition />
                            </Grid.ColumnDefinitions>


                            <StackPanel Orientation="Vertical" Grid.Column="0" Grid.Row="1">

                                <!--<StackPanel Orientation="Horizontal" Margin="10,20,20,22" >-->

                                <StackPanel  Orientation="Horizontal" HorizontalAlignment="Stretch" 
                                        Margin="10,10,20,0" Grid.Column="0" Grid.Row="1">

                                    <Label Name="lblRPIMessages" Content="Most Recently Recieved Message" FontFamily="Trebuchet MS" 
                                            FontSize="12" FontWeight="Bold" Height="28" 
                                            HorizontalAlignment="Center" Margin="30,10,20,0" 
                                            VerticalAlignment="Center"  Foreground="#FF1A1A17" />

                                    <Label Name="lblMostRecentMessage" FontFamily="Trebuchet MS" 
                                            FontWeight="Bold" Height="25" HorizontalAlignment="Stretch" 
                                            Margin="20,10,68,10" VerticalAlignment="Stretch" VerticalContentAlignment="Center" 
                                            Width="479" Foreground="#FF112705" Background="LemonChiffon"/>
                                </StackPanel>
                            </StackPanel>

                            <StackPanel  Orientation="Vertical" HorizontalAlignment="Stretch" Grid.Column="0" Grid.Row="2">

                                <Label Content="Reporting Facility Interface Results" FontWeight="Bold" Height="34" HorizontalAlignment="Left" 
                                       Margin="30,0,10,0" Name="lblRPIResults" 
                                       VerticalAlignment="Center"  Foreground="#FF1A1A17"/>

                                <TextBox AcceptsReturn="True" Margin="30,0,20,10" Name="txtRPIResults" TextWrapping="Wrap" VerticalAlignment="Center" 
                                    HorizontalAlignment="Stretch" Height="100" removed="LemonChiffon"/>
                            </StackPanel>
                            <StackPanel Orientation="Horizontal" HorizontalAlignment="Stretch" Grid.Column="0" Grid.Row="3">
                                <Button Name="btnClearResults" Content="Clear Results" Height="23" HorizontalAlignment="Center"  VerticalAlignment="Center"  
                                FontFamily="Trebuchet MS" FontWeight="Bold"  Click="btnClearResults_Click" Margin="20,10,30,10"/>

                            </StackPanel>
                        </Grid>
                    </TabItem>
                </TabControl>

            </Border>
        </StackPanel>
    </Grid>
</Window> 

I've attached a snipped screen shot showing the behaviour I'm currently getting.

Any suggestions/help would be greatly appreciated.

Thanks,
JohnB 
Posted
Comments
Sergey Alexandrovich Kryukov 26-Apr-13 12:24pm    
Just a note: it looks like you need to specify more exactly the behavior you need, and explain what's wrong right now, also exactly...
—SA

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900