This is a migrated thread and some comments may be shown as answers.

Scroll Bar issue when Start sized column presents

0 Answers 33 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Gopi
Top achievements
Rank 1
Gopi asked on 14 May 2012, 02:03 PM
Hi Support Team,

In my grid i have placed a star sized column (width = "*") at the right, but while resizing the window, the column size itself adjusting instead of content size. That makes the horizontal Scroll doesn;t visible.

Also when i place the same grid inside a Scroll Viewer, the star sized column width is set to a big size. I don;t know which value it is taking. Its very difficult for the user to scroll and view the data as well.

When i make the fixed with columns (width = "150") the scroll viewer works, but i have two issues on that.

1. its not expands / shirinks when resolutions is increased / decreased.
2. There is an additional column displayed at the end. (In my case i have my own style for colum headers, that additional column doesn;t applied to that style).

Here is the Code.

XAML :

<UserControl x:Class="SilverlightApplicationDemoDG.GridViewColumnSizing"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
             mc:Ignorable="d">
  
    <Grid x:Name="LayoutRoot" Background="White">
  
        <Grid.RowDefinitions>
            <RowDefinition></RowDefinition>
            <RowDefinition></RowDefinition>
        </Grid.RowDefinitions>
  
        <ScrollViewer  Grid.Row="0" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto">
  
            <telerik:RadGridView Name="SampleGrid1" 
                                 IsReadOnly="True" 
                                 RowIndicatorVisibility="Collapsed" 
                                 ShowGroupPanel="False" 
                                 AllowDrop="False" 
                                 ShowInsertRow="False" 
                                 AutoGenerateColumns="False" 
                                 HorizontalAlignment="Stretch" 
                                 VerticalAlignment="Stretch" 
                                 ScrollViewer.HorizontalScrollBarVisibility="Auto"
                                 ScrollViewer.VerticalScrollBarVisibility="Auto">
  
  
                <telerik:RadGridView.ColumnGroups>
                    <telerik:GridViewColumnGroup Name="SampleGroup1"/>
                </telerik:RadGridView.ColumnGroups>
  
                <telerik:RadGridView.Columns>
  
                    <telerik:GridViewDataColumn Header="Code" 
                                                HeaderTextAlignment="Left" 
                                                Width="57"  
                                                IsSortable="False" 
                                                IsFilterable="False" 
                                                DataMemberBinding="{Binding Code}"
                                                ColumnGroupName="SampleGroup1">
                        <telerik:GridViewColumn.CellTemplate>
                            <DataTemplate>
                                <TextBlock Text="{Binding Code}" TextAlignment="Center"/>
                            </DataTemplate>
                        </telerik:GridViewColumn.CellTemplate>
                    </telerik:GridViewDataColumn>
  
                    <telerik:GridViewDataColumn Header="Label" 
                                                Width="*" 
                                                HeaderTextAlignment="Center"
                                                IsSortable="False"
                                                IsFilterable="False"
                                                DataMemberBinding="{Binding Label}"
                                                ColumnGroupName="SampleGroup1">
                        <telerik:GridViewColumn.CellTemplate>
                            <DataTemplate>
                                <TextBlock Text="{Binding Label}" TextAlignment="Center"/>
                            </DataTemplate>
                        </telerik:GridViewColumn.CellTemplate>
  
                    </telerik:GridViewDataColumn>
                </telerik:RadGridView.Columns>
  
            </telerik:RadGridView>
  
        </ScrollViewer>
  
  
        <telerik:RadGridView Name="SampleGrid2" 
                             IsReadOnly="True" 
                             RowIndicatorVisibility="Collapsed" 
                             ShowGroupPanel="False" 
                             AllowDrop="False" 
                             ShowInsertRow="False" 
                             AutoGenerateColumns="False" 
                             HorizontalAlignment="Stretch" 
                             VerticalAlignment="Stretch" 
                             ScrollViewer.HorizontalScrollBarVisibility="Auto"
                             ScrollViewer.VerticalScrollBarVisibility="Auto"
                             Grid.Row="1">
  
            <telerik:RadGridView.ColumnGroups>
                <telerik:GridViewColumnGroup Name="SampleGroup2"/>
            </telerik:RadGridView.ColumnGroups>
  
            <telerik:RadGridView.Columns>
  
                <telerik:GridViewDataColumn Header="Code" 
                                            HeaderTextAlignment="Left" 
                                            Width="57"  
                                            IsSortable="False" 
                                            IsFilterable="False" 
                                            DataMemberBinding="{Binding Code}"
                                            ColumnGroupName="SampleGroup2">
                    <telerik:GridViewColumn.CellTemplate>
                        <DataTemplate>
                            <TextBlock Text="{Binding Code}" TextAlignment="Center"/>
                        </DataTemplate>
                    </telerik:GridViewColumn.CellTemplate>
                </telerik:GridViewDataColumn>
  
                <telerik:GridViewDataColumn Header="Label" 
                                                Width="*" 
                                                HeaderTextAlignment="Center"
                                                IsSortable="False"
                                                IsFilterable="False"
                                                DataMemberBinding="{Binding Label}"
                                                ColumnGroupName="SampleGroup2">
                    <telerik:GridViewColumn.CellTemplate>
                        <DataTemplate>
                            <TextBlock Text="{Binding Label}" TextAlignment="Center"/>
                        </DataTemplate>
                    </telerik:GridViewColumn.CellTemplate>
  
                </telerik:GridViewDataColumn>
  
            </telerik:RadGridView.Columns>
  
        </telerik:RadGridView>
  
  
  
    </Grid>
</UserControl>

Code Behind :

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Collections.ObjectModel;
  
namespace SilverlightApplicationDemoDG
{
    public partial class GridViewColumnSizing : UserControl
    {
        private ObservableCollection<codes> collection;
  
        public GridViewColumnSizing()
        {
            InitializeComponent();
            SetDataSource();
        }
  
        private void SetDataSource()
        {
            collection = new ObservableCollection<codes>();
            collection.Add(new codes { Label = "Test Data ", Code = "1" });
            collection.Add(new codes { Label = "Test Data For Trail", Code = "1" });
            collection.Add(new codes { Label = "The Quick Brown fox jumps over the lazy dog.", Code = "1" });
            collection.Add(new codes { Label = "The Quick Brown fox jumps over the lazy dog.", Code = "1" });
            collection.Add(new codes { Label = "The Quick Brown fox jumps over the lazy dog. The Quick Brown fox jumps over the lazy dog.", Code = "1" });
            collection.Add(new codes { Label = "Test", Code = "1" });
            collection.Add(new codes { Label = "Test", Code = "1" });
            collection.Add(new codes { Label = "Test", Code = "1" });
            collection.Add(new codes { Label = "Test", Code = "1" });
            collection.Add(new codes { Label = "Test", Code = "1" });
            collection.Add(new codes { Label = "Test", Code = "1" });
            collection.Add(new codes { Label = "Test", Code = "1" });
            collection.Add(new codes { Label = "Test", Code = "1" });
            collection.Add(new codes { Label = "Test", Code = "1" });
  
            SampleGrid1.ItemsSource = collection;
            SampleGrid2.ItemsSource = collection;
        }
  
    }
  
    public class codes
    {
        public string Code { get; set; }
  
        public string Label { get; set; }
    }
}

Can you please tell me, how to i enable scroll bars without the resolution barriers.

Thanks in Advance.

Regards,
Gopi V



No answers yet. Maybe you can help?

Tags
GridView
Asked by
Gopi
Top achievements
Rank 1
Share this question
or