|
@@ -2,10 +2,16 @@
|
|
|
using System.Collections.Generic;
|
|
|
using System.Linq;
|
|
|
using System.Windows;
|
|
|
+using System.Windows.Controls;
|
|
|
+using System.Windows.Data;
|
|
|
+using System.Windows.Markup;
|
|
|
using System.Windows.Media;
|
|
|
using InABox.Core;
|
|
|
+using InABox.WPF;
|
|
|
+using RoslynPad.Editor;
|
|
|
using Syncfusion.Windows.Shared;
|
|
|
using Syncfusion.Windows.Tools.Controls;
|
|
|
+using ItemsPanelTemplate = System.Windows.Controls.ItemsPanelTemplate;
|
|
|
|
|
|
namespace InABox.DynamicGrid
|
|
|
{
|
|
@@ -15,6 +21,7 @@ namespace InABox.DynamicGrid
|
|
|
static CheckListEditorControl()
|
|
|
{
|
|
|
//DynamicEditorControlFactory.Register<CheckListEditorControl, CheckListEditor>();
|
|
|
+
|
|
|
}
|
|
|
|
|
|
private SolidColorBrush _color;
|
|
@@ -34,11 +41,8 @@ namespace InABox.DynamicGrid
|
|
|
public override void Configure()
|
|
|
{
|
|
|
if (EditorDefinition is not CheckListEditor editor) return;
|
|
|
-
|
|
|
- Width = editor.LookupWidth;
|
|
|
- Editor.IsEnabled = false;
|
|
|
- Editor.Background = Brushes.WhiteSmoke;
|
|
|
-
|
|
|
+ Editor.ItemsPanel = GetItemsPanelTemplate(editor.Width);
|
|
|
+ Editor.ItemContainerStyle = GetItemsContainerStyle(editor.ColumnWidth);
|
|
|
Host.LoadLookups(this);
|
|
|
}
|
|
|
|
|
@@ -61,20 +65,50 @@ namespace InABox.DynamicGrid
|
|
|
SetupCheckListBox();
|
|
|
}
|
|
|
|
|
|
+ private class WidthConverter : AbstractConverter<double, double>
|
|
|
+ {
|
|
|
+ public CheckListEditorControl Parent { get; set; }
|
|
|
+
|
|
|
+ public override double Convert(double value)
|
|
|
+ {
|
|
|
+ return value - 10.0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private ItemsPanelTemplate? GetItemsPanelTemplate(double width)
|
|
|
+ {
|
|
|
+ FrameworkElementFactory fc = new FrameworkElementFactory(typeof(WrapPanel));
|
|
|
+ var binding = new Binding()
|
|
|
+ {
|
|
|
+ RelativeSource = new RelativeSource(RelativeSourceMode.FindAncestor, typeof(CheckListBox), 1),
|
|
|
+ Path = new PropertyPath(nameof(ActualWidth)),
|
|
|
+ Converter = new WidthConverter() { Parent = this }
|
|
|
+ };
|
|
|
+ fc.SetBinding(WidthProperty,binding);
|
|
|
+ //fc.SetValue(BackgroundProperty, new SolidColorBrush(Colors.LightBlue));
|
|
|
+ ItemsPanelTemplate ipt = new ItemsPanelTemplate(fc);
|
|
|
+ return ipt;
|
|
|
+ }
|
|
|
+
|
|
|
+ private Style? GetItemsContainerStyle(double width)
|
|
|
+ {
|
|
|
+ var style = new Style(typeof(CheckListBoxItem));
|
|
|
+ style.Setters.Add(new Setter {Property = WidthProperty, Value = width});
|
|
|
+ //style.Setters.Add(new Setter {Property = BackgroundProperty, Value = new SolidColorBrush(Colors.Red)});
|
|
|
+ return style;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
protected override FrameworkElement CreateEditor()
|
|
|
{
|
|
|
- MinHeight = 50;
|
|
|
+
|
|
|
Editor = new CheckListBox
|
|
|
{
|
|
|
- VerticalAlignment = VerticalAlignment.Stretch,
|
|
|
- VerticalContentAlignment = VerticalAlignment.Top,
|
|
|
- HorizontalAlignment = HorizontalAlignment.Stretch,
|
|
|
- //SelectedItemBackground = Brushes.Transparent,
|
|
|
- //Foreground = Brushes.Black
|
|
|
DisplayMemberPath = "Value",
|
|
|
- SelectedValuePath = "Key"
|
|
|
+ SelectedValuePath = "Key",
|
|
|
+ HorizontalAlignment = HorizontalAlignment.Stretch
|
|
|
};
|
|
|
- SkinStorage.SetVisualStyle(Editor, "Metro");
|
|
|
+ //SkinStorage.SetVisualStyle(Editor, "Metro");
|
|
|
Editor.SelectionChanged += (o, e) =>
|
|
|
{
|
|
|
if (!bLoading)
|
|
@@ -85,7 +119,7 @@ namespace InABox.DynamicGrid
|
|
|
|
|
|
public override int DesiredWidth()
|
|
|
{
|
|
|
- return 150;
|
|
|
+ return int.MaxValue;
|
|
|
}
|
|
|
|
|
|
protected override Dictionary<string, bool> RetrieveValue()
|