My WPF application permits users to select from a collection of <UserControl/> at runtime.
Each <UserControl/> is loaded as content to a RadPane. Each RadPane, RadPaneGroup
and RadSplitContainer has a unique serialization tag:
I have created an event handler for ElementSaving. At the point we are saving a RadPane, I
want to serialize the contents (which is a user-selected <UserControl/> as above):
My first question: Am I on the right track with this approach, or has Telerik implemented
some functionality that would permit a cleaner approach? I note a reference to a method
called GetPaneContent() at this link in the Silverlight forum. Is that a reference to some
user-created method... or is it a method provided by Telerik?
Each <UserControl/> is loaded as content to a RadPane. Each RadPane, RadPaneGroup
and RadSplitContainer has a unique serialization tag:
internal
void
UserControlToRADPane(UserControl theControl,
string
theName)
{
RadSplitContainer leftContainer =
new
RadSplitContainer() { InitialPosition = DockState.DockedLeft };
RadPaneGroup group =
new
RadPaneGroup() { Name =
"RPG"
+ (++_radPaneGroupId).ToString() };
RadPane aPane =
new
RadPane() { Header = theName, Content = theControl };
RadDocking.SetSerializationTag(leftContainer,
"rsp_"
+ leftContainer.Name +
"_tag"
+ (++_aStaticIntValue).ToString());
RadDocking.SetSerializationTag(group,
"rpg_"
+ group.Name +
"_tag"
+ (++_aStaticIntValue).ToString());
RadDocking.SetSerializationTag(aPane,
"rp_"
+ aPane.Header +
"_tag"
+ (++_aStaticIntValue).ToString());
group.AddItem(aPane, DockPosition.Center);
leftContainer.Items.Add(group);
MainDockingManager01.Items.Add(leftContainer);
}
I have created an event handler for ElementSaving. At the point we are saving a RadPane, I
want to serialize the contents (which is a user-selected <UserControl/> as above):
private
void
dockingManager01_ElementSaving(
object
sender, LayoutSerializationEventArgs args)
{
// Since we are accessing UI elements, we need ownership and
// the quickest way to get that is to run on the STA thread.
if
(args.AffectedElement.GetType() ==
typeof
(Telerik.Windows.Controls.RadPane))
{
var uc = ((RadPane)args.AffectedElement).Content
as
UserControl;
ViewModel.VMDockingManager01.Instance.ElementSaving(sender, args, uc);
}
else
ViewModel.VMDockingManager01.Instance.ElementSaving(sender, args);
}
My first question: Am I on the right track with this approach, or has Telerik implemented
some functionality that would permit a cleaner approach? I note a reference to a method
called GetPaneContent() at this link in the Silverlight forum. Is that a reference to some
user-created method... or is it a method provided by Telerik?