Hi,
I've been experimenting a little with the PersistenceFramework over the course of the day and I've found some, according to me,
mystic behaviour.
When the window containing my RadGridView closes I run this code:
and when I open it up again the following code is run:
For the sake of things it should be noted that I have a RadContextMenu loading in order to be able to show/hide columns in the RadGridView.
Now, here's to the tricky bit, I have a RadContextMenu where the user can set the visibility of the columns, and IF the user ONLY uses this, everything is fine and dandy, visibility properties as set as they should upon reload. However IF the user decides to rearrange the columns, the next time he/she opens up the window, ALL columns are gone, there's NOTHING there at all.
So in short:
* Show / Hide columns using the RadContextMenu bound to the RadGridView works fine, persistence is kept and loads nicely.
* Rearrange columns and the persistence is broken and no columns as viewable upon opening the window.
As a little twist, the columns are all visible in the ContextMenu and their visibility are set as they should, but the GridView doesn't display them.
A little help, please?
P.S
I run the following version of the Telerik components:
RadControls_for_WPF_2013_1_0527_DEV_hotfix
D.S
I've been experimenting a little with the PersistenceFramework over the course of the day and I've found some, according to me,
mystic behaviour.
When the window containing my RadGridView closes I run this code:
var manager =
new
PersistenceManager();
var stream = manager.Save(dgOrderOverview);
using
(var fileStream = File.Create(System.AppDomain.CurrentDomain.BaseDirectory +
"\\objstore.hf"
))
{
stream.CopyTo(fileStream);
}
and when I open it up again the following code is run:
//Check if any persistence file exists, and if so, load the view
if
(File.Exists(System.AppDomain.CurrentDomain.BaseDirectory +
"\\objstore.hf"
))
{
var manager =
new
PersistenceManager();
try
{
var fileStream = File.OpenRead(System.AppDomain.CurrentDomain.BaseDirectory +
"\\objstore.hf"
);
manager.Load(dgOrderOverview, fileStream);
fileStream.Close();
}
catch
(Exception ex)
{
System.Diagnostics.Debug.WriteLine(ex.Message,
"MYAPPNAME"
);
}
}
//Load Context Menu
RadContextMenu ctxMenu =
new
RadContextMenu();
RadMenuItem item =
new
RadMenuItem();
foreach
(Telerik.Windows.Controls.GridViewColumn column
in
dgOrderOverview.Columns)
{
RadMenuItem sitem =
new
RadMenuItem() { Header = column.Header, IsCheckable =
true
, IsChecked =
true
};
sitem.SetBinding(RadMenuItem.IsCheckedProperty,
new
Binding(
"IsVisible"
) { Mode = BindingMode.TwoWay, Source = column });
ctxMenu.Items.Add(sitem);
}
RadContextMenu.SetContextMenu(dgOrderOverview, ctxMenu);
For the sake of things it should be noted that I have a RadContextMenu loading in order to be able to show/hide columns in the RadGridView.
Now, here's to the tricky bit, I have a RadContextMenu where the user can set the visibility of the columns, and IF the user ONLY uses this, everything is fine and dandy, visibility properties as set as they should upon reload. However IF the user decides to rearrange the columns, the next time he/she opens up the window, ALL columns are gone, there's NOTHING there at all.
So in short:
* Show / Hide columns using the RadContextMenu bound to the RadGridView works fine, persistence is kept and loads nicely.
* Rearrange columns and the persistence is broken and no columns as viewable upon opening the window.
As a little twist, the columns are all visible in the ContextMenu and their visibility are set as they should, but the GridView doesn't display them.
A little help, please?
P.S
I run the following version of the Telerik components:
RadControls_for_WPF_2013_1_0527_DEV_hotfix
D.S