Hi,
Using the Loaded event to call column.GetFittedWidth() through a dispatcher works as expected in Toolkit v3.0 and up.
Here's my complete sample :
b) Can you submit a complete sample if it's still not working for you ?
Thanks.
――――
Get more controls, features, updates and technical support with Xceed Toolkit Plus for WPF
Using the Loaded event to call column.GetFittedWidth() through a dispatcher works as expected in Toolkit v3.0 and up.
Here's my complete sample :
<Window x:Class="WpfApplication118.MainWindow"
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"
xmlns:local="clr-namespace:WpfApplication118"
mc:Ignorable="d"
xmlns:xcdg="http://schemas.xceed.com/wpf/xaml/datagrid"
Title="MainWindow" Height="350" Width="525">
<Grid>
<xcdg:DataGridControl ItemsSource="{Binding}"
Loaded="DataGridControl_Loaded"
AutoCreateColumns="True" />
</Grid>
</Window> public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
this.DataContext = new ObservableCollection<MyItemViewModel>()
{
new MyItemViewModel() { ID = 1, FirstName = "Brian the top Jones", Birthday = DateTime.Now },
new MyItemViewModel() { ID = 10, FirstName = "Michael the great one", Birthday = DateTime.Now },
new MyItemViewModel() { ID = 100, FirstName = "Tom the coolest QB on earth", Birthday = DateTime.Now },
new MyItemViewModel() { ID = 1000, FirstName = "Mark Fitzpatrickeneski von Guarted", Birthday = DateTime.Now },
};
}
private void DataGridControl_Loaded( object sender, RoutedEventArgs e )
{
var grid = sender as DataGridControl;
this.Dispatcher.Invoke( DispatcherPriority.ApplicationIdle, new Action( delegate ()
{
foreach( Column column in grid.Columns )
{
double width = column.GetFittedWidth();
if( width > 0 )
column.Width = width;
}
} ) );
}
}
public class MyItemViewModel
{
public int ID
{
get;
set;
}
public string FirstName
{
get;
set;
}
public DateTime Birthday
{
get;
set;
}
}
a) 125 is the default column's widthb) Can you submit a complete sample if it's still not working for you ?
Thanks.
――――
Get more controls, features, updates and technical support with Xceed Toolkit Plus for WPF