Update StandardControl rendering, so happens after properties set
This commit is contained in:
Родитель
70921b1089
Коммит
5d95f637e1
|
@ -1,26 +1,18 @@
|
||||||
using Microsoft.StandardUI.Controls;
|
using Microsoft.StandardUI.Controls;
|
||||||
using System;
|
using System;
|
||||||
using System.Windows;
|
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
|
|
||||||
namespace Microsoft.StandardUI.Wpf
|
namespace Microsoft.StandardUI.Wpf
|
||||||
{
|
{
|
||||||
public class StandardControl<TControl> : System.Windows.Controls.Control, IControl, IStandardControlEnvironmentPeer where TControl : IControl
|
public class StandardControl<T> : System.Windows.Controls.Control, IControl, IStandardControlEnvironmentPeer where T : IControl
|
||||||
{
|
{
|
||||||
private StandardControlImplementation<TControl> _implementation;
|
private StandardControlImplementation<T> _implementation;
|
||||||
private StandardUIFrameworkElement? _buildContent;
|
private StandardUIFrameworkElement? _buildContent;
|
||||||
|
private bool _invalid = true;
|
||||||
|
|
||||||
protected void InitImplementation(StandardControlImplementation<TControl> implementation)
|
protected void InitImplementation(StandardControlImplementation<T> implementation)
|
||||||
{
|
{
|
||||||
_implementation = implementation;
|
_implementation = implementation;
|
||||||
|
|
||||||
_buildContent = (StandardUIFrameworkElement?)implementation.Build();
|
|
||||||
|
|
||||||
if (_buildContent != null)
|
|
||||||
{
|
|
||||||
AddVisualChild(_buildContent);
|
|
||||||
AddLogicalChild(_buildContent);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void IUIElement.Measure(Size availableSize)
|
void IUIElement.Measure(Size availableSize)
|
||||||
|
@ -37,11 +29,17 @@ namespace Microsoft.StandardUI.Wpf
|
||||||
|
|
||||||
IUIPropertyObject? IControl.GetTemplateChild(string childName)
|
IUIPropertyObject? IControl.GetTemplateChild(string childName)
|
||||||
{
|
{
|
||||||
throw new System.NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override System.Windows.Size MeasureOverride(System.Windows.Size constraint)
|
protected override System.Windows.Size MeasureOverride(System.Windows.Size constraint)
|
||||||
{
|
{
|
||||||
|
if (_invalid)
|
||||||
|
{
|
||||||
|
Rebuild();
|
||||||
|
_invalid = false;
|
||||||
|
}
|
||||||
|
|
||||||
_implementation.Measure(new Size(constraint.Width, constraint.Height));
|
_implementation.Measure(new Size(constraint.Width, constraint.Height));
|
||||||
return _implementation.DesiredSize.ToWpfSize();
|
return _implementation.DesiredSize.ToWpfSize();
|
||||||
}
|
}
|
||||||
|
@ -88,6 +86,24 @@ namespace Microsoft.StandardUI.Wpf
|
||||||
return _buildContent;
|
return _buildContent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void Rebuild()
|
||||||
|
{
|
||||||
|
if (_buildContent != null)
|
||||||
|
{
|
||||||
|
RemoveVisualChild(_buildContent);
|
||||||
|
RemoveLogicalChild(_buildContent);
|
||||||
|
_buildContent = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
_buildContent = (StandardUIFrameworkElement?)_implementation.Build();
|
||||||
|
|
||||||
|
if (_buildContent != null)
|
||||||
|
{
|
||||||
|
AddVisualChild(_buildContent);
|
||||||
|
AddLogicalChild(_buildContent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#if false
|
#if false
|
||||||
IControlTemplate? IControl.Template
|
IControlTemplate? IControl.Template
|
||||||
{
|
{
|
||||||
|
|
|
@ -2,11 +2,11 @@
|
||||||
|
|
||||||
namespace Microsoft.StandardUI.Controls
|
namespace Microsoft.StandardUI.Controls
|
||||||
{
|
{
|
||||||
public abstract class StandardControlImplementation<TControl> where TControl : IControl
|
public abstract class StandardControlImplementation<T> where T : IControl
|
||||||
{
|
{
|
||||||
public TControl Control { get; }
|
public T Control { get; }
|
||||||
|
|
||||||
public StandardControlImplementation(TControl control)
|
public StandardControlImplementation(T control)
|
||||||
{
|
{
|
||||||
Control = control;
|
Control = control;
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче