Skip to main content

Microsoft Silverlight

Answered Question how do I position a datagrid (with scollviewer) within the .aspx page correctly?RSS Feed

(0)

hazz
hazz

Member

Member

75 points

259 Posts

how do I position a datagrid (with scollviewer) within the .aspx page correctly?

1. The datagrid and working horiz scroll are much wider than the browser page it is hosted on. 1. The vertical scrollbar is not working as per code/markup below. 3. The First Column is NOT frozen when scrolling horizontally.  Thank you for any help.  -greg

Here is the xaml

<UserControl xmlns:data="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data"  x:Class="XTO_Silverlight_WCF_CurrentSummary.Page"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Width="1500" Height="500">
    <Grid x:Name="LayoutRoot" Background="White">
     <ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto">
      <data:DataGrid HorizontalAlignment="Left"
                     Margin="0,0,0,0"
                     VerticalAlignment="Top"
                     x:Name="XTOGrid"
                     FrozenColumnCount="1"
                     Width="1500"
                     Height="500"
                     CanUserResizeColumns="True">
    </data:DataGrid>
   </ScrollViewer>
  </Grid>
</UserControl>

 and here is the .aspx page the .xap derived from the xaml above is hosted on.

<%@ Page Language="C#" AutoEventWireup="true" %>

<%@ Register Assembly="System.Web.Silverlight" Namespace="System.Web.UI.SilverlightControls"
    TagPrefix="asp" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" style="height:100%;">
<head runat="server">
    <title>XTO_Silverlight_WCF_CurrentSummary</title>
</head>
<body style="height:100%;margin:0;">
    <form id="form1" runat="server" style="height:100%;">
        <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
        <div  style="height:100%;">
            <asp:Silverlight ID="Xaml1" runat="server" Source="~/ClientBin/XTO_Silverlight_WCF_CurrentSummary.xap" MinimumVersion="2.0.31005.0" Width="100%" Height="100%" />
        </div>
    </form>
</body>
</html>
 

hazz

hazz
hazz

Member

Member

75 points

259 Posts

Answered Question

Re: how do I position a datagrid (with scollviewer) within the .aspx page correctly?

Setting all the widths and heights to 'Auto' is the answer.

 

<UserControl xmlns:data="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data"  x:Class="XTO_Silverlight_WCF_CurrentSummary.Page"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    Width="Auto" Height="Auto">
    <Grid x:Name="LayoutRoot" Background="White">
        <ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto">
      <data:DataGrid HorizontalAlignment="Left" 
                     Margin="0,0,0,0" 
                     VerticalAlignment="Top"
                     x:Name="XTOGrid" 
                     FrozenColumnCount="1"
                     Width="Auto" 
                     Height="Auto"
                     CanUserResizeColumns="True">
    </data:DataGrid>
   </ScrollViewer>
  </Grid>
</UserControl>
 

hazz
  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities