Solved

limiting width of silverlight datagrid

Posted on 2011-09-19
3
422 Views
Last Modified: 2012-05-12
I'm working through the WCF RIA Services application tutorial off of silverlight.net and I'm trying to understand how to set the size of the datagrid so that it does not run off the right side of the screen.
<navigation:Page x:Class="HRApp.EmployeeList" 
           xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
           xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
           xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
           xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
           mc:Ignorable="d"
           xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
           xmlns:ds="clr-namespace:HRApp.Web"
           xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"
           xmlns:riaControls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.DomainServices"
           xmlns:dataForm="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data.DataForm.Toolkit"
           d:DesignWidth="640" d:DesignHeight="480"
           Title="EmployeeList Page">
           
    <Grid x:Name="LayoutRoot">
        
        <ScrollViewer x:Name="PageScrollViewer" Style="{StaticResource PageScrollViewerStyle}">

            <StackPanel x:Name="ContentStackPanel" Style="{StaticResource ContentStackPanelStyle}">

                <TextBlock x:Name="HeaderText" Text="Employee List" Style="{StaticResource HeaderTextStyle}"/>
                <StackPanel Orientation="Horizontal"
                            HorizontalAlignment="Right"
                            Margin="0, -16, 0, 0">
                    <TextBlock VerticalAlignment="Center"
                               Text="Min Vacation Hours Filter" />
                    <TextBox x:Name="vacationHoursText" Width="75" FontSize="11" Margin="4" Text="0" />
                </StackPanel>
                
                    <riaControls:DomainDataSource Name="employeeDataSource" LoadSize="20" QueryName="GetDimSalariedEmployees" AutoLoad="True" >
                        <riaControls:DomainDataSource.DomainContext>
                            <ds:OrganizationContext></ds:OrganizationContext>
                        </riaControls:DomainDataSource.DomainContext>
                        <riaControls:DomainDataSource.SortDescriptors>
                            <riaControls:SortDescriptor PropertyPath="VacationHours" Direction="Ascending" />
                        </riaControls:DomainDataSource.SortDescriptors>
                        <riaControls:DomainDataSource.FilterDescriptors>
                            <riaControls:FilterDescriptor
                                PropertyPath="VacationHours"
                                Operator="IsGreaterThanOrEqualTo"
                                IgnoredValue=""
                                Value="{Binding ElementName=vacationHoursText, Path=Text}">
                            </riaControls:FilterDescriptor>
                        </riaControls:DomainDataSource.FilterDescriptors>
                    </riaControls:DomainDataSource>

                    <sdk:DataGrid AutoGenerateColumns="True" Name="dataGrid1" MinHeight="100" Height="Auto" IsReadOnly="True" ItemsSource="{Binding Data, ElementName=employeeDataSource}"/>

                <sdk:DataPager Height="26" Name="dataPager1" PageSize="5" Source="{Binding Data, ElementName=employeeDataSource}" Margin="0, -1, 0, 0" />

                <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,12,0,0">
                        <Button x:Name="addNewEmployee" Width="90" Height="23"  Content="Add Employee"  Margin="4,0,0,0" Click="addNewEmployee_Click"/>
                    </StackPanel>
                
                    <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,12,0,0">
                        <Button x:Name="submitButton" Width="75" Height="23"  Content="Submit" Margin="4,0,0,0" Click="submitButton_Click"/>
                        <Button x:Name="approveSabbatical" Width="115" Height="23"  Content="Approve Sabbatical"  Margin="4,0,0,0" Click="approveSabbatical_Click"/>
                    </StackPanel>

            </StackPanel>

        </ScrollViewer>
        
    </Grid>
</navigation:Page>

Open in new window

0
Comment
Question by:PeterTrefren
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
3 Comments
 

Author Comment

by:PeterTrefren
ID: 36564033
What I would like is to have the datagrid width not be larger then the width of the stack panel it is inside.
0
 

Accepted Solution

by:
PeterTrefren earned 0 total points
ID: 36564204
When I removed the ScrollViewer I was able to get the datagrid to behave as intended.
0
 

Author Closing Comment

by:PeterTrefren
ID: 36564206
This did the trick.
0

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question