Solved

limiting width of silverlight datagrid

Posted on 2011-09-19
3
414 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
  • 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

910 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now