Kaynağa Gözat

MasterDetailPanel no longer XAML-defined.

Kenric Nugteren 1 yıl önce
ebeveyn
işleme
0222c85a71

+ 41 - 4
inabox.wpf/MasterDetailPanel/MasterDetailPanel.xaml.cs → inabox.wpf/MasterDetailPanel/MasterDetailPanel.cs

@@ -3,6 +3,7 @@ using System.Collections.Generic;
 using System.ComponentModel;
 using System.Linq;
 using System.Windows.Controls;
+using System.Windows.Media;
 using System.Windows.Threading;
 using InABox.Configuration;
 using InABox.Core;
@@ -42,8 +43,6 @@ public abstract class MasterDetailPanel<TMaster, TMasterGrid, TSettings> : Maste
         new UserConfiguration<TSettings>().Save(Settings);
     }
     
-    protected abstract string MasterCaption { get; }
-    protected abstract string DetailCaption { get; }
     protected abstract void CreatePages();
     protected abstract void AfterLoadSettings(TSettings settings);
     protected abstract void BeforeSaveSettings(TSettings settings);
@@ -213,12 +212,50 @@ public abstract class MasterDetailPanel<TMaster, TMasterGrid, TSettings> : Maste
     
 }
 
-public abstract partial class MasterDetailPanel : UserControl
+public abstract class MasterDetailPanel : UserControl
 {
+    protected DynamicSplitPanel _splitPanel;
+    protected Label _header;
+    protected DynamicTabControl _tabControl;
+
+    protected abstract string MasterCaption { get; }
+    protected abstract string DetailCaption { get; }
+
     
     protected MasterDetailPanel()
     {
-        InitializeComponent();
+        _splitPanel = new DynamicSplitPanel
+        {
+            View = DynamicSplitPanelView.Combined,
+            AnchorWidth = 300,
+            MasterCaption = MasterCaption,
+            DetailCaption = DetailCaption
+        };
+        _splitPanel.OnChanged += SplitPanel_OnChanged;
+
+        _header = new Label
+        {
+            HorizontalContentAlignment = System.Windows.HorizontalAlignment.Center,
+            VerticalContentAlignment = System.Windows.VerticalAlignment.Center,
+        };
+
+        _splitPanel.Header = new Border
+        {
+            BorderBrush = new SolidColorBrush(Colors.Gray),
+            BorderThickness = new System.Windows.Thickness(0.75),
+            Background = new SolidColorBrush(Colors.WhiteSmoke),
+            Height = 25,
+            Child = _header
+        };
+
+        _tabControl = new DynamicTabControl();
+        Grid.SetColumn(_tabControl, 2);
+        Grid.SetRow(_tabControl, 0);
+        Grid.SetRowSpan(_tabControl, 2);
+        _tabControl.SelectionChanged += Pages_OnChanged;
+        _splitPanel.Detail = _tabControl;
+
+        Content = _splitPanel;
     }
 
     protected abstract void DoSplitPanelChanged();

+ 0 - 43
inabox.wpf/MasterDetailPanel/MasterDetailPanel.xaml

@@ -1,43 +0,0 @@
-<UserControl x:Class="InABox.Wpf.MasterDetailPanel"
-             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
-             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
-             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
-             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
-             xmlns:dynamicGrid="clr-namespace:InABox.DynamicGrid"
-             mc:Ignorable="d"
-             d:DesignHeight="300" d:DesignWidth="300" Background="WhiteSmoke">
-    
-    <dynamicGrid:DynamicSplitPanel 
-        x:Name="_splitPanel" 
-        View="Combined" 
-        AnchorWidth="300" 
-        MasterCaption="{Binding MasterCaption}"
-        DetailCaption="{Binding DetailCaption}"
-        OnChanged="SplitPanel_OnChanged">
-
-        <dynamicGrid:DynamicSplitPanel.Header>
-            <Border 
-                BorderBrush="Gray" 
-                BorderThickness="0.75" 
-                Background="WhiteSmoke" 
-                Height="25">
-                <Label 
-                    x:Name="_header" 
-                    HorizontalContentAlignment="Center"
-                    VerticalContentAlignment="Center" />
-            </Border>
-        </dynamicGrid:DynamicSplitPanel.Header>
-
-        <dynamicGrid:DynamicSplitPanel.Detail>
-            <dynamicGrid:DynamicTabControl 
-                x:Name="_tabControl" 
-                Grid.Column="2" 
-                Grid.Row="0" 
-                Grid.RowSpan="2"
-                SelectionChanged="Pages_OnChanged" >
-                
-            </dynamicGrid:DynamicTabControl>
-        </dynamicGrid:DynamicSplitPanel.Detail>
-
-    </dynamicGrid:DynamicSplitPanel>
-</UserControl>