Hello,
I have been struggling with the GridView to get it to display my data as my ObservableCollection changes. It appears that the grid is only updating when the user moves a scroll bar. How can I make my grid update as my collection does, without messing up my scroll position. I attempted using the Rebind() method to get it to refresh, but the scroll bar resetting is unacceptable.
Here is a little information about my setup.
I am using the WPF Rad Controls Q2 2012 edition.
My Observable collection is a two dimensional collection that looks like this:
Here is what the LogField Class looks like:
I am setting up the columns manually and here is what the column setup and binding look like.
I have wasted a lot of time on this issue and I am just looking for a solution, so I can move forward.
Hope to hear something soon,
Brian
I have been struggling with the GridView to get it to display my data as my ObservableCollection changes. It appears that the grid is only updating when the user moves a scroll bar. How can I make my grid update as my collection does, without messing up my scroll position. I attempted using the Rebind() method to get it to refresh, but the scroll bar resetting is unacceptable.
Here is a little information about my setup.
I am using the WPF Rad Controls Q2 2012 edition.
My Observable collection is a two dimensional collection that looks like this:
private ObservableCollection<ObservableCollection<LogField>> _RowData;public ObservableCollection<ObservableCollection<LogField>> RowData{ get { return _RowData; } set { if (value != _RowData) { _RowData = value; onPropertyChanged(this, "RowData"); } }}Here is what the LogField Class looks like:
public class LogField : INotifyPropertyChanged { private byte _HighlighFlag; public byte HighlightFlag { get { return _HighlighFlag; } set { if (value != _HighlighFlag) { _HighlighFlag = value; onPropertyChanged(this, "HighlightFlag"); } } } private string _Value; public string Value { get { return _Value; } set { if (value != _Value) { _Value = value; onPropertyChanged(this, "Value"); } } } private string _DisplayUnits; public string DisplayUnits { get { return _DisplayUnits; } set { if (value != _DisplayUnits) { _DisplayUnits = value; onPropertyChanged(this, "DisplayUnits"); } } } private string _BaseUnits; public string BaseUnits { get { return _BaseUnits; } set { if (value != _BaseUnits) { _BaseUnits = value; onPropertyChanged(this, "BaseUnits"); } } } private byte _FieldType; public byte FieldType { get { return _FieldType; } set { if (value != _FieldType) { _FieldType = value; onPropertyChanged(this, "FieldType"); } } } private string _FieldFormat; public string FieldFormat { get { return _FieldFormat; } set { if (value != _FieldFormat) { _FieldFormat = value; onPropertyChanged(this, "FieldFormat"); } } } private int _SelectOffset; public int SelectOffset { get { return _SelectOffset; } set { if (value != _SelectOffset) { _SelectOffset = value; onPropertyChanged(this, "SelectOffset"); } } } private int _UnitNumber; public int UnitNumber { get { return _UnitNumber; } set { if (value != _UnitNumber) { _UnitNumber = value; onPropertyChanged(this, "UnitNumber"); } } } public event PropertyChangedEventHandler PropertyChanged; private void onPropertyChanged(object sender, string propertyName) { if (this.PropertyChanged != null) { PropertyChanged(sender, new PropertyChangedEventArgs(propertyName)); } } }I am setting up the columns manually and here is what the column setup and binding look like.
// Initialize the radGridView with the propper settings for a log screen.int columnIndex = 0;thisMMGridView.Height = 280;LogScreen logScreen = (LogScreen)thisMMGridView.CurrentScreen;thisMMGridView.radGridView.AutoGenerateColumns = false;thisMMGridView.radGridView.Columns.Clear();// Build the columns based on the headerStringsforeach (string headerString in logScreen.ColumnHeaderStrings){ GridViewDataColumn column = new GridViewDataColumn(); // Create the column header TextBlock headerText = new TextBlock(); headerText.Text = headerString; headerText.TextWrapping = TextWrapping.Wrap; headerText.TextAlignment = TextAlignment.Left; headerText.Padding = new Thickness(1, 0, 2, 0); column.HeaderCellStyle = thisMMGridView.TryFindResource("AlarmGridViewHeaderCellStyle") as Style; column.Header = headerText; column.UniqueName = headerString; thisMMGridView.radGridView.Columns.Add(column); // Bind the column to it's data column.DataMemberBinding = new Binding("["+ columnIndex.ToString() +"].Value"); // Bump the column index that is used for the columnBind columnIndex++;}// Freeze the time & date columns so they are always visibleif (thisMMGridView.radGridView.Columns[1].UniqueName == "DATE"){ thisMMGridView.radGridView.FrozenColumnCount = 2;}else{ thisMMGridView.radGridView.FrozenColumnCount = 1;}// Set the ItemsSource property of the grid to the data collection.thisMMGridView.radGridView.ItemsSource = thisMMGridView.Unit.LogData.RowData;I have wasted a lot of time on this issue and I am just looking for a solution, so I can move forward.
Hope to hear something soon,
Brian