-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMainWindow.xaml.cs
50 lines (49 loc) · 1.88 KB
/
MainWindow.xaml.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
using DevExpress.Xpf.Core;
using DevExpress.Xpf.Core.Serialization;
using DevExpress.Xpf.Docking;
using System.Windows;
namespace DXWpfApplication {
public partial class MainWindow : ThemedWindow {
const string LayoutPath = "layout.xml";
const string App = "DXWpfApplication";
//
public MainWindow() {
InitializeComponent();
}
void ButtonSave_Click(object sender, System.Windows.RoutedEventArgs e) {
panel2.Prop1 = 117;
MyCustomPanel.SetProp2(panel3, 287);
DXSerializer.Serialize(this, LayoutPath, App,
new DXOptionsLayout() { AcceptNestedObjects = AcceptNestedObjects.VisualTreeOnly }
);
}
void ButtonRestore_Click(object sender, System.Windows.RoutedEventArgs e) {
panel2.Prop1 = 0;
MyCustomPanel.SetProp2(panel3, 0);
DXSerializer.Deserialize(this, LayoutPath, App,
new DXOptionsLayout() { AcceptNestedObjects = AcceptNestedObjects.VisualTreeOnly }
);
}
}
class TestData {
public string Text { get; set; }
public int Number { get; set; }
}
//
class MyCustomPanel : LayoutPanel {
public static readonly DependencyProperty Prop2Property;
static MyCustomPanel() {
Prop2Property = DependencyProperty.RegisterAttached("Prop2", typeof(int), typeof(MyCustomPanel), new PropertyMetadata(0));
}
//
[DevExpress.Utils.Serializing.XtraSerializableProperty]
public static int GetProp2(DependencyObject obj) {
return (int)obj.GetValue(Prop2Property);
}
public static void SetProp2(DependencyObject obj, int value) {
obj.SetValue(Prop2Property, value);
}
[DevExpress.Utils.Serializing.XtraSerializableProperty]
public int Prop1 { get; set; }
}
}