<Window x:Class="RadControlsWpfApp1.MainWindow" xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation" Title="MainWindow" Height="550" Width="800"> <Grid> <telerik:RadPanelBar Name="radPanelBar1"> <telerik:RadPanelBarItem Header="Item 1" /> <telerik:RadPanelBarItem Header="Item 2" /> </telerik:RadPanelBar> </Grid></Window><telerik:RadDatePicker HorizontalAlignment="Left" Margin="28,90,0,0" Name="radDatePicker1" VerticalAlignment="Top" Width="223" SelectedValue="{Binding Path=BoundDate}" />/// <summary>/// Gets the BoundDate property./// Changes to that property's value raise the PropertyChanged event. /// This property's value is broadcasted by the Messenger's default instance when it changes./// </summary>public DateTime BoundDate{ get { return _boundDate; } set { if (_boundDate == value) { return; } var oldValue = _boundDate; _boundDate = value; // Update bindings and broadcast change using GalaSoft.MvvmLight.Messenging RaisePropertyChanged(BoundDatePropertyName, oldValue, value, true); }}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Telerik.Windows.Persistence;
using Telerik.Windows.Persistence.Storage;
namespace WpfApplication_Docking
{
static public class PersistenceStorage
{
#region Public methods.
/// <summary>
/// Load/Save all controls that contain "telerik:PersistenceManager.StorageId="..."
/// The file location is "$APPDATA\IsolatedStorage\..."
/// </summary>
/// <param name="pPersistenceAction">Load/Save</param>
/// <param name="pErrorMessage">Error received during the persistence.</param>
/// <returns>true if successfull otherwise false</returns>
static public bool Persist(PersistenceAction pPersistenceAction, out string pErrorMessage)
{
pErrorMessage = string.Empty;
PersistenceManager manager = new PersistenceManager();
//manager.PropertyPersisting += new Telerik.Windows.Persistence.Events.PropertyPersistingEventHandler(manager_PropertyPersisting);
IsolatedStorageProvider storage = new IsolatedStorageProvider(manager);
try
{
try
{
if (pPersistenceAction == PersistenceAction.Load)
{
storage.LoadFromStorage();
}
else if (pPersistenceAction == PersistenceAction.Save)
{
storage.SaveToStorage();
}
return true;
}
catch (Exception ex)
{
pErrorMessage = ex.Message;
return false;
}
}
finally
{
//manager.PropertyPersisting += new Telerik.Windows.Persistence.Events.PropertyPersistingEventHandler(manager_PropertyPersisting);
}
}
/// <summary>
/// Event triggered when the stream persistence didn't worked.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
static void manager_PersistenceError(object sender, Telerik.Windows.Persistence.Events.PersistenceErrorEventArgs e)
{
mErrorMessage = e.Exception.Message;
mResult = false;
throw new NotImplementedException();
}
/// <summary>
/// This event is used to prevent any BroderBrush to have a transparent color when we persist an object.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
static void manager_PropertyPersisting(object sender, Telerik.Windows.Persistence.Events.PersistingPropertyEventArgs e)
{
//Not needed since version 2011.3.1116.35 of Telerik
//if (e.Name == "BorderBrush")
// e.Cancel = true;
}
#endregion
#region Enumerators.
public enum PersistenceAction { Load, Save }
#endregion
#region Private declarations.
static private string mErrorMessage;
static private bool mResult;
#endregion
}
}