Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1060
Column width not work with Scrollvieweer
posted

I am facing a problem when HorizontalScrollBarVisibility="Visible" OR HorizontalScrollBarVisibility="Auto" of ScrollViewer object is set then Grid column width is not working and giving unexpected result.

Here my control XAML.

<UserControl
    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:igGrid="clr-namespace:Infragistics.Silverlight.Controls;assembly=Infragistics.Silverlight.XamWebGrid.v10.1" x:Class="SilverlightApplication3.MainPage"
    >
    <ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto" >
        <Grid x:Name="LayoutRoot"  MinWidth="600" MinHeight="350">
           
            <igGrid:XamWebGrid x:Name="myGrid"  ScrollViewer.HorizontalScrollBarVisibility="Hidden" ScrollViewer.VerticalScrollBarVisibility="Hidden"  AutoGenerateColumns="False" d:LayoutOverrides="Width, Height" Height="110" VerticalAlignment="Top"/>
           
        </Grid>
    </ScrollViewer>
</UserControl>

 

and Here is my Code Behind file.

public partial class MainPage : UserControl
    {
        public MainPage()
        {
            InitializeComponent();
            List<CustomClass> lst = new List<CustomClass>();
            for (int i = 0; i < 15; i++)
            {
                lst.Add(new CustomClass { Name = "Name " + i.ToString(), Val1 = i.ToString(), Val2 = i.ToString() });
            }
            TextColumn tc1 = new TextColumn();
            tc1.Key = "Name";
            tc1.Width = new ColumnWidth(0.5, true);
            TextColumn tc2 = new TextColumn();
            tc2.Key = "Val1";
            tc2.Width = new ColumnWidth(0.25, true);
            TextColumn tc3 = new TextColumn();
            tc3.Key = "Val2";
            tc3.Width = new ColumnWidth(0.25, true);
            myGrid.Columns.Insert(0, tc1);
            myGrid.Columns.Insert(1, tc2);
            myGrid.Columns.Insert(2, tc3);
            myGrid.UpdateLayout();
            myGrid.ItemsSource = lst;
        }
    }
    public class CustomClass
    {
        public string Name { get; set; }
        public string Val1 { get; set; }
        public string Val2 { get; set; }
    }

Here is the output????

is it a bug in Grid? Kindly reply me soon as I will have to take decision soon. Thanks

 

Best Regards,

Parents
  • 40030
    Verified Answer
    Offline posted

    Hi, 

    If you put the xamGrid into a container that gives the control Infinite Width, then we cannot support star sizing, as its based off the remaining width of the control.  Not to mention you'll loose virtualization. 

    If you must put the xamGrid into a scrollViewer, then you should set a Height and Width on it, so that sizing can be performed like you expect and so that virtualization is on. 

    -SteveZ

Reply Children