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
Solved

limiting width of silverlight datagrid

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Linq asp.net mvc 13 17
MailAddress in vb 4 29
System.net.Sockets Error 5 26
DataGridView / get bound table name? 8 24
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…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used.

792 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