Hello,
I create dynamically my columns through an attached property and can't seem to set the string format for my columns. I would like my number have the format 1234.00 > 1,234.00
How to do that ?
I tried with:
in my .xaml:
in my view model :
in GridViewDataColumnsBehavior:
I create dynamically my columns through an attached property and can't seem to set the string format for my columns. I would like my number have the format 1234.00 > 1,234.00
How to do that ?
I tried with:
in my .xaml:
<telerik:RadGridView x:Name="RadGridView1" ItemsSource="{Binding ResultsViewModelList}" AutoGenerateColumns="False" custom:GridViewDataColumnsBehavior.BindableColumns="{Binding ColumnCollection}"
...in my view model :
// Toggle Column
GridViewToggleRowDetailsColumn gridRowToggle = new GridViewToggleRowDetailsColumn();
ColumnCollection.Add(gridRowToggle);
//data column
GridViewDataColumn column = new GridViewDataColumn(); string columnName = "column1"; column.Header = columnName; column.UniqueName = columnName; column.DataMemberBinding = new Binding("ResultDataDictionary[" + columnName + "]"); column.DataMemberBinding.StringFormat = "0:N"; //also tried with N , {0:N}, ...//also tried > column.DataFormatString = "0:N"; column.DataType = typeof(double);ColumnCollection.Add(column);in GridViewDataColumnsBehavior:
public static readonly DependencyProperty BindableColumnsProperty = DependencyProperty.RegisterAttached("BindableColumns", typeof(ObservableCollection<GridViewColumn>), typeof(GridViewDataColumnsBehavior), new UIPropertyMetadata(null, BindableColumnsPropertyChanged)); private static void BindableColumnsPropertyChanged(DependencyObject source, DependencyPropertyChangedEventArgs e) { RadGridView RadGridView = source as RadGridView; ObservableCollection<GridViewColumn> columns = e.NewValue as ObservableCollection<GridViewColumn>; RadGridView.Columns.Clear(); if (columns == null) { return; } foreach (GridViewColumn column in columns) { RadGridView.Columns.Add(column); }.....