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

set GridViewDataColumn width GridViewLengthUnitType.Star stop working in .2012.2.912.40 version

5 Answers 264 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Insight
Top achievements
Rank 1
Insight asked on 18 Sep 2012, 06:29 PM
I want to set the column width to take the whole table sixe (fill) with the code below

gvColumn2.Width =

new GridViewLength(1, GridViewLengthUnitType.Star);

It worked fine with Telerik version 2012 Q1. However, it doesn't work when I installed  Telerik WPF v.2012.2.912.40.

Please suggest!
Thanks and regards

 

5 Answers, 1 is accepted

Sort by
0
Accepted
Vlad
Telerik team
answered on 19 Sep 2012, 05:46 AM
Hi,

 I've just tried this however everything worked as expected on our my end. You can check the attached project for more info. 

Greetings,
Vlad
the Telerik team

Time to cast your vote for Telerik! Tell DevPro Connections and Windows IT Pro why Telerik is your choice. Telerik is nominated in a total of 25 categories.

0
Insight
Top achievements
Rank 1
answered on 19 Sep 2012, 06:04 PM
It doesn't work in a particular case.
I can't attached the updated project here. Please use your project and copy the code below.
The gridview is created progammatically, it is nested in expander and within a tabitem of Tabcontrol. It works until the expander is placed within the Tabcontrol. Please review and suggest.


MainWindow.xaml:

<Window x:Class="WpfApplication1.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
        Title="MainWindow" Height="500" Width="525">
    <Grid>
        <StackPanel>
            <TabControl Name="tabProjectIntegrity"
                                    VerticalContentAlignment="Stretch" VerticalAlignment="Stretch">
                <TabItem x:Name="tabQuickSelect" Header="First Tab">
                </TabItem>
                <TabItem Header="Second Tab" >
                    <ScrollViewer VerticalScrollBarVisibility="Auto" Grid.Row="0">
                        <StackPanel x:Name="content" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"></StackPanel>
                    </ScrollViewer>
                </TabItem>
                </TabControl>
        </StackPanel>     

    </Grid>
</Window>


MainWindow.xaml.cs

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Telerik.Windows.Controls;

namespace WpfApplication1
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();

            DataContext = from i in Enumerable.Range(0, 100) select new { ID = i, Name = string.Format("Name{0}", i) };

            for (int i = 1; i <= 2; i++)
            {
                RadGridView newRadGridView = new RadGridView();
                newRadGridView.AutoGenerateColumns = false;
                newRadGridView.CanUserDeleteRows = false;
                newRadGridView.CanUserFreezeColumns = false;
                newRadGridView.CanUserInsertRows = false;
                newRadGridView.CanUserReorderColumns = false;
                newRadGridView.CanUserResizeColumns = true;
                newRadGridView.CanUserSelect = true;
                newRadGridView.CanUserSortColumns = false;
                newRadGridView.EnableColumnVirtualization = false;
                newRadGridView.EnableRowVirtualization = false;
                //newRadGridView.Width = newCategoryExpander.Width - 145;

                //newRadGridView.Margin = new Thickness(10);
                newRadGridView.HorizontalAlignment = HorizontalAlignment.Stretch;
                newRadGridView.IsFilteringAllowed = true;
                newRadGridView.IsHitTestVisible = true;
                newRadGridView.IsReadOnly = true;
                newRadGridView.IsSynchronizedWithCurrentItem = true;
                newRadGridView.ItemsSource = DataContext;
                newRadGridView.Margin = new Thickness(4);
                newRadGridView.RowIndicatorVisibility = Visibility.Collapsed;
                newRadGridView.SelectionMode = SelectionMode.Multiple;
                newRadGridView.ShowGroupPanel = false;
                //newRadGridView.Style = (Style)Application.Current.FindResource("InforTelerikGridView");
                //StyleManager.SetTheme(newRadGridView, new Windows7Theme());

                //Create two new grid view columns
                Telerik.Windows.Controls.GridViewColumn gvColumn1 = new Telerik.Windows.Controls.GridViewSelectColumn();
                Telerik.Windows.Controls.GridViewColumn gvColumn2 = new Telerik.Windows.Controls.GridViewDataColumn();

                //Set the unique names of the columns and the width of the second column
                gvColumn1.UniqueName = "ROW_SELECT";
                //gvColumn1.Header = "ID";
                //gvColumn1.Style = (Style)Application.Current.FindResource("InforTelerikGridViewSelectColumnStyle");

                //gvColumn2.Style = (Style)Application.Current.FindResource("InforTelerikGridViewDataColumnStyle");
                gvColumn2.UniqueName = "Name";
                gvColumn2.Header = "Name";
                gvColumn2.Width = new Telerik.Windows.Controls.GridViewLength(1, Telerik.Windows.Controls.GridViewLengthUnitType.Star);

                //Add the columns to the grid
                newRadGridView.Columns.Add(gvColumn1);
                newRadGridView.Columns.Add(gvColumn2);

                //Dont select any rows on load 
                newRadGridView.Focusable = false;
                newRadGridView.UnselectAll();

                Expander newCategoryExpander = new Expander();

                newCategoryExpander.Header = "My Expander";
                newCategoryExpander.IsExpanded = false;
                newCategoryExpander.Width = double.NaN;
                newCategoryExpander.Content = newRadGridView;
                //newCategoryExpander.IsExpanded = true;

                //Add the grid to the expander
                content.Children.Add(newCategoryExpander);
            }
        }

 

    }
}

0
Accepted
Vlad
Telerik team
answered on 20 Sep 2012, 05:42 AM
Hi,

I've reviewed your setup however I believe that this is not the proper way to work with ItemsControls and especially grids - definitely this worked incidentally with our Q2 version.

Have you noticed that RadGridView vertical scrollbar is missing? Your grid currently is measured with both infinity height and width and it is completely unusable. You cannot scroll it nor you can see the records outside of the initial viewport. 

I've attached the same example with standard WPF DataGrid for reference - you will get exactly the same result. 

Regards,
Vlad
the Telerik team

Time to cast your vote for Telerik! Tell DevPro Connections and Windows IT Pro why Telerik is your choice. Telerik is nominated in a total of 25 categories.

0
Insight
Top achievements
Rank 1
answered on 21 Sep 2012, 05:42 PM
Dear Vlad,
Thank you for your response. However, I am not clear on your suggestion. The sample of standard WPF DataGrid you gave aslo have the same issue!
To make it's easier on attaching the reference code, I am opening a ticket for this issue.

Thanks again for your help.

0
Vlad
Telerik team
answered on 24 Sep 2012, 05:34 AM
Hello,

 What I'm trying to say is that your setup is not correct for both Telerik and standard WPF components.

Please revise your XAML!

Regards,
Vlad
the Telerik team

Time to cast your vote for Telerik! Tell DevPro Connections and Windows IT Pro why Telerik is your choice. Telerik is nominated in a total of 25 categories.

Tags
GridView
Asked by
Insight
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Insight
Top achievements
Rank 1
Share this question
or