string _title;
string _subtitle;
StackLayout _contentView;
+ LayoutOptions _horizontalOption = LayoutOptions.Center;
+ LayoutOptions _verticalOption = LayoutOptions.End;
+
+ LayoutOptions _previousHorizontalOption = LayoutOptions.Center;
bool _isDisposed = false;
}
}
+ public LayoutOptions HorizontalOption
+ {
+ get
+ {
+ return _horizontalOption;
+ }
+ set
+ {
+ _horizontalOption = value;
+ OnPropertyChanged();
+ }
+ }
+
+ public LayoutOptions VerticalOption
+ {
+ get
+ {
+ return _verticalOption;
+ }
+ set
+ {
+ _verticalOption = value;
+ OnPropertyChanged();
+ }
+ }
+
public void Show()
{
_control.Show();
{
UpdateSubtitle();
}
+ else if (e.PropertyName == Dialog.HorizontalOptionProperty.PropertyName)
+ {
+ UpdateHorizontalOption();
+ }
+ else if (e.PropertyName == Dialog.VerticalOptionProperty.PropertyName)
+ {
+ UpdateVerticalOption();
+ }
}
void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
_control.SetPartText("subtitle,text", Subtitle);
}
+
+ void UpdateHorizontalOption()
+ {
+ switch (HorizontalOption.Alignment)
+ {
+ case LayoutAlignment.Start:
+ _control.AlignmentX = 0.0;
+ break;
+
+ case LayoutAlignment.Center:
+ _control.AlignmentX = 0.5;
+ break;
+
+ case LayoutAlignment.End:
+ _control.AlignmentX = 1.0;
+ break;
+
+ case LayoutAlignment.Fill:
+ _control.AlignmentX = -1;
+ break;
+ }
+ if (HorizontalOption.Alignment == LayoutAlignment.Fill)
+ {
+ UpdateContent();
+ _previousHorizontalOption = HorizontalOption;
+ }
+ else
+ {
+ if (_previousHorizontalOption.Alignment == LayoutAlignment.Fill)
+ {
+ UpdateContent();
+ _previousHorizontalOption = HorizontalOption;
+ }
+ }
+ }
+
+ void UpdateVerticalOption()
+ {
+ switch (VerticalOption.Alignment)
+ {
+ case LayoutAlignment.Start:
+ _control.AlignmentY = 0.0;
+ break;
+
+ case LayoutAlignment.Center:
+ _control.AlignmentY = 0.5;
+ break;
+
+ case LayoutAlignment.End:
+ _control.AlignmentY = 1.0;
+ break;
+
+ case LayoutAlignment.Fill:
+ _control.AlignmentY = -1;
+ break;
+ }
+ }
}
}
\ No newline at end of file
/// </summary>
public static readonly BindableProperty SubtitleProperty = BindableProperty.Create(nameof(Subtitle), typeof(string), typeof(Dialog), null);
+ /// <summary>
+ /// BindableProperty.Identifies the HorizontalOption bindable property.
+ /// </summary>
+ public static readonly BindableProperty HorizontalOptionProperty = BindableProperty.Create(nameof(HorizontalOption), typeof(LayoutOptions), typeof(Dialog), LayoutOptions.Center);
+
+ /// <summary>
+ /// BindableProperty.Identifies the VerticalOption bindable property.
+ /// </summary>
+ public static readonly BindableProperty VerticalOptionProperty = BindableProperty.Create(nameof(VerticalOption), typeof(LayoutOptions), typeof(Dialog), LayoutOptions.End);
+
IDialog _dialog = null;
/// <summary>
SetBinding(NegativeProperty, new Binding(nameof(Negative), mode: BindingMode.TwoWay, source: _dialog));
SetBinding(TitleProperty, new Binding(nameof(Title), mode: BindingMode.TwoWay, source: _dialog));
SetBinding(SubtitleProperty, new Binding(nameof(Subtitle), mode: BindingMode.TwoWay, source: _dialog));
+ SetBinding(HorizontalOptionProperty, new Binding(nameof(HorizontalOption), mode: BindingMode.TwoWay, source: _dialog));
+ SetBinding(VerticalOptionProperty, new Binding(nameof(VerticalOption), mode: BindingMode.TwoWay, source: _dialog));
}
/// <summary>
}
/// <summary>
+ /// Gets or sets the LayoutOptions that define how the Dialog gets laid in a layout cycle
+ /// </summary>
+ public LayoutOptions HorizontalOption
+ {
+ get { return (LayoutOptions)GetValue(HorizontalOptionProperty); }
+ set { SetValue(HorizontalOptionProperty, value); }
+ }
+
+ /// <summary>
+ /// Gets or sets the LayoutOptions that define how the Dialog gets laid in a layout cycle
+ /// </summary>
+ public LayoutOptions VerticalOption
+ {
+ get { return (LayoutOptions)GetValue(VerticalOptionProperty); }
+ set { SetValue(VerticalOptionProperty, value); }
+ }
+
+ /// <summary>
/// Shows the Dialog.
/// </summary>
public void Show()