private EventHandler<StateChangedEventArgs> stateChangeHandler;
private bool isPressed = false;
- private bool styleApplied = false;
+ internal int styleApplying = 0;
/// <summary>
/// Gets accessibility name.
[EditorBrowsable(EditorBrowsableState.Never)]
protected void UpdateState()
{
- if (!styleApplied) return;
+ if (styleApplying > 0) return;
ControlState sourceState = ControlState;
ControlState targetState;
buttonIcon = CreateIcon();
LayoutItems();
-#if PROFILE_MOBILE
Feedback = true;
-#endif
}
/// <inheritdoc/>
{
isPressed = statePressed;
}
+
+ if (IsSelectable)
+ {
+ var stateSelected = controlStateChangedInfo.CurrentState.Contains(ControlState.Selected);
+
+ if (IsSelected != stateSelected)
+ {
+ IsSelected = stateSelected;
+ }
+ }
}
/// <summary>
Size2D cellPadding = String.IsNullOrEmpty(buttonText.Text) ? new Size2D(0, 0) : itemSpacing;
#pragma warning restore CA2000
- // If LayoutItems() is called by OnInitialize(), then layout would be null.
- // Because layout is set by ApplyStyle() which is called after OnInitialize().
- var layout = Layout as LinearLayout;
- if (layout != null)
- {
- layout.HorizontalAlignment = itemHorizontalAlignment;
- layout.VerticalAlignment = itemVerticalAlignment;
- layout.CellPadding = cellPadding;
- }
-
if (IconRelativeOrientation == IconOrientation.Left)
{
- if (layout != null)
+ Layout = new LinearLayout()
{
- layout.LinearOrientation = LinearLayout.Orientation.Horizontal;
- }
+ LinearOrientation = LinearLayout.Orientation.Horizontal,
+ HorizontalAlignment = itemHorizontalAlignment,
+ VerticalAlignment = itemVerticalAlignment,
+ CellPadding = cellPadding
+ };
Add(buttonIcon);
Add(buttonText);
}
else if (IconRelativeOrientation == IconOrientation.Right)
{
- if (layout != null)
+ Layout = new LinearLayout()
{
- layout.LinearOrientation = LinearLayout.Orientation.Horizontal;
- }
+ LinearOrientation = LinearLayout.Orientation.Horizontal,
+ HorizontalAlignment = itemHorizontalAlignment,
+ VerticalAlignment = itemVerticalAlignment,
+ CellPadding = cellPadding
+ };
Add(buttonText);
Add(buttonIcon);
}
else if (IconRelativeOrientation == IconOrientation.Top)
{
- if (layout != null)
+ Layout = new LinearLayout()
{
- layout.LinearOrientation = LinearLayout.Orientation.Vertical;
- }
+ LinearOrientation = LinearLayout.Orientation.Vertical,
+ HorizontalAlignment = itemHorizontalAlignment,
+ VerticalAlignment = itemVerticalAlignment,
+ CellPadding = cellPadding
+ };
Add(buttonIcon);
Add(buttonText);
}
else if (IconRelativeOrientation == IconOrientation.Bottom)
{
- if (layout != null)
+ Layout = new LinearLayout()
{
- layout.LinearOrientation = LinearLayout.Orientation.Vertical;
- }
+ LinearOrientation = LinearLayout.Orientation.Vertical,
+ HorizontalAlignment = itemHorizontalAlignment,
+ VerticalAlignment = itemVerticalAlignment,
+ CellPadding = cellPadding
+ };
Add(buttonText);
Add(buttonIcon);
if (iconRelativeOrientation == IconOrientation.Left || iconRelativeOrientation == IconOrientation.Right)
{
- lengthWithoutText += (itemSpacing?.Width ?? 0) + iconMargin.Start + iconMargin.End + textMargin.Start + textMargin.End;
+ lengthWithoutText += (itemSpacing?.Width ?? 0) + iconMargin.Start + iconMargin.End + textMargin.Start + textMargin.End + Padding.Start + Padding.End;
}
else
{
- lengthWithoutText += (itemSpacing?.Height ?? 0) + iconMargin.Top + iconMargin.Bottom + textMargin.Top + textMargin.Bottom;
+ lengthWithoutText += (itemSpacing?.Height ?? 0) + iconMargin.Top + iconMargin.Bottom + textMargin.Top + textMargin.Bottom + Padding.Top + Padding.Bottom;
}
}
}