Solved

limiting width of silverlight datagrid

Posted on 2011-09-19
3
408 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
Comment Utility
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
Comment Utility
When I removed the ScrollViewer I was able to get the datagrid to behave as intended.
0
 

Author Closing Comment

by:PeterTrefren
Comment Utility
This did the trick.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that undeā€¦
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

771 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

9 Experts available now in Live!

Get 1:1 Help Now