base.OnElementChanged(e);
}
- void UpdateColor()
+ void UpdateColor(bool initialize)
{
+ if (initialize && Element.Color.IsDefault)
+ return;
+
Control.Color = (Element.Color == Color.Default) ? s_defaultColor : Element.Color.ToNative();
}
base.OnElementPropertyChanged(sender, e);
}
- protected override void UpdateBackgroundColor()
+ protected override void UpdateBackgroundColor(bool initialize)
{
- UpdateColor();
+ if (initialize && Element.BackgroundColor.IsDefault)
+ return;
+
+ if (Element.Color.IsDefault)
+ {
+ UpdateColor();
+ }
}
- protected override void UpdateOpacity()
+ protected override void UpdateOpacity(bool initialize)
{
+ if (initialize && Element.Opacity == 1d)
+ return;
+
UpdateColor();
}
protected override void UpdateThemeStyle()
{
- Control.UpdateStyle(Specific.GetStyle(Element));
- ((IVisualElementController)Element).NativeSizeChanged();
+ var style = Specific.GetStyle(Element);
+ if (!string.IsNullOrEmpty(style))
+ {
+ Control.UpdateStyle(style);
+ ((IVisualElementController)Element).NativeSizeChanged();
+ }
}
void UpdateBorder()
base.OnElementChanged(e);
}
- protected override void UpdateBackgroundColor()
+ protected override void UpdateBackgroundColor(bool initialize)
{
+ if (initialize && Element.BackgroundColor.IsDefault)
+ return;
+
// base.UpdateBackgroundColor() is not called on purpose, we don't want the regular background setting
if (Element.BackgroundColor.IsDefault || Element.BackgroundColor.A == 0)
_page.Color = EColor.Transparent;
// empty on purpose
}
- void UpdateBackgroundImage()
+ void UpdateBackgroundImage(bool initiaize)
{
+ if (initiaize && string.IsNullOrWhiteSpace(Element.BackgroundImage))
+ return;
+
if (string.IsNullOrWhiteSpace(Element.BackgroundImage))
_page.File = null;
else
Control.FontAttributes = Element.FontAttributes;
}
- void UpdateKeyboard()
+ void UpdateKeyboard(bool initialize)
{
+ if (initialize && Element.Keyboard == Keyboard.Default)
+ return;
+
Control.Keyboard = Element.Keyboard.ToNative();
}
}
Control.HorizontalTextAlignment = Element.HorizontalTextAlignment.ToNative();
}
- void UpdateKeyboard()
+ void UpdateKeyboard(bool initialize)
{
+ if (initialize && Element.Keyboard == Keyboard.Default)
+ return;
+
Control.Keyboard = Element.Keyboard.ToNative();
}
/// <summary>
/// Updates the height of the row.
/// </summary>
- void UpdateRowHeight()
+ void UpdateRowHeight(bool initialize)
{
+ if (initialize)
+ return;
+
Control.UpdateRealizedItems();
}
var _switch = new Check(Forms.Context.MainWindow)
{
PropagateEvents = false,
+ Style = SwitchStyle.Toggle
};
SetNativeControl(_switch);
}
protected override void UpdateThemeStyle()
{
var style = Specific.GetStyle(Element);
+ if (string.IsNullOrEmpty(style))
+ {
+ return;
+ }
switch (style)
{
case SwitchStyle.Toggle:
return new ESize(NativeView.MinimumWidth, NativeView.MinimumHeight);
}
- protected virtual void UpdateBackgroundColor()
+ protected virtual void UpdateBackgroundColor(bool initialize)
{
+ if (initialize && Element.BackgroundColor.IsDefault)
+ return;
+
if (NativeView is Widget)
{
(NativeView as Widget).BackgroundColor = Element.BackgroundColor.ToNative();
}
}
- protected virtual void UpdateOpacity()
+ protected virtual void UpdateOpacity(bool initialize)
{
+ if (initialize && Element.Opacity == 1d)
+ return;
+
if (NativeView is Widget)
{
(NativeView as Widget).Opacity = (int)(Element.Opacity * 255.0);
/// <summary>
/// Updates the IsEnabled property.
/// </summary>
- void UpdateIsEnabled()
+ void UpdateIsEnabled(bool initialize)
{
+ if (initialize && Element.IsEnabled)
+ return;
+
var widget = NativeView as Widget;
if (widget != null)
{
/// <summary>
/// Updates the InputTransparent property.
/// </summary>
- void UpdateInputTransparent()
+ void UpdateInputTransparent(bool initialize)
{
+ if (initialize && Element.InputTransparent == default(bool))
+ return;
+
NativeView.PassEvents = Element.InputTransparent;
}
}
}
- void UpdateToolTip()
+ void UpdateToolTip(bool initialize)
{
var tooltip = Specific.GetToolTip(Element);
if (tooltip != null)
{
NativeView.SetTooltipText(tooltip);
}
- else
+ else if (!initialize)
{
NativeView.UnsetTooltip();
}