Skip to main content
Home Forums Silverlight Programming Silverlight Controls and Silverlight Toolkit how do I position a datagrid (with scollviewer) within the .aspx page correctly?
1 replies. Latest Post by hazz on December 31, 2008.
(0)
hazz
Member
75 points
259 Posts
12-31-2008 11:07 AM |
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>
12-31-2008 11:57 AM |
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>