Solved

limiting width of silverlight datagrid

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

730 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