namespace Tizen.Xamarin.Forms.Extension
{
+ /// <summary>
+ /// The ContextPopup class allows a contextual popup to be anchored at a View.
+ /// </summary>
+ /// <example>
+ /// <code>
+ /// ContextPopup popup = new ContextPopup();
+ /// popup.Items.Add(new ContextPopupItem("Text only item"));
+ /// popup.Items.Add(new ContextPopupItem("Home icon", "home"));
+ /// popup.SelectedIndexChanged += (s, e) =>
+ /// {
+ /// var ctxPopup = s as ContextPopup;
+ /// Debug.WriteLine("Item with index {0} selected", ctxPopup.SelectedIndex);
+ /// Debug.WriteLine("It has label: " + (ctxPopup.SelectedItem as ContextPopupItem).Label);
+ /// };
+ ///
+ /// Button btn = new Button
+ /// {
+ /// Text = "Toggle popup"
+ /// };
+ /// btn.Clicked += (s, e) =>
+ /// {
+ /// popup.Show(s as Button);
+ /// popupShowing = true;
+ /// };
+ /// </code>
+ /// </example>
public class ContextPopup : BindableObject
{
IContextPopup _contextPopup;
SetBinding(SelectedItemProperty, new Binding(nameof(SelectedItem), mode: BindingMode.TwoWay, source: _contextPopup));
}
+ /// <summary>
+ /// Occurs when the ContextPopup is dismissed.
+ /// </summary>
public event EventHandler Dismissed;
+ /// <summary>
+ /// Occurs when an item is selected.
+ /// </summary>
public event EventHandler SelectedIndexChanged;
+ /// <summary>
+ /// Gets or sets the orientation of the ContextPopup.
+ /// The default value is ContextPopupOrientation.Vertical.
+ /// </summary>
public ContextPopupOrientation Orientation
{
get { return (ContextPopupOrientation)GetValue(OrientationProperty); }
set { SetValue(OrientationProperty, value); }
}
+ /// <summary>
+ /// Gets or sets whether the ContextPopup will hide automatically when the background is selected
+ /// or parent geometry is updated.
+ /// The default value is true.
+ /// </summary>
public bool IsAutoHidingEnabled
{
get { return (bool)GetValue(IsAutoHidingEnabledProperty); }
set { SetValue(IsAutoHidingEnabledProperty, value); }
}
+ /// <summary>
+ /// Gets or sets the direction priorities for the ContextPopup.
+ /// </summary>
public ContextPopupDirectionPriorities DirectionPriorities
{
get { return (ContextPopupDirectionPriorities)GetValue(DirectionPrioritiesProperty); }
set { SetValue(DirectionPrioritiesProperty, value); }
}
+ /// <summary>
+ /// Gets or sets the index of the selected item of the ContextPopup.
+ /// It is -1 when no item is selected.
+ /// </summary>
public int SelectedIndex
{
get { return (int)GetValue(SelectedIndexProperty); }
set { SetValue(SelectedIndexProperty, value); }
}
+ /// <summary>
+ /// Gets or sets the selected item of the ContextPopup.
+ /// </summary>
public object SelectedItem
{
get { return (ContextPopupItem)GetValue(SelectedItemProperty); }
set { SetValue(SelectedItemProperty, value); }
}
+ /// <summary>
+ /// Gets or sets the source list of items for the ContextPopup.
+ /// </summary>
public IList ItemsSource
{
get { return (IList)GetValue(ItemsSourceProperty); }
set { SetValue(ItemsSourceProperty, value); }
}
+ /// <summary>
+ /// Gets the list of items in the ContextPopup.
+ /// </summary>
public IList<ContextPopupItem> Items
{
get
}
}
+ /// <summary>
+ /// Shows the ContextPopup.
+ /// </summary>
+ /// <param name="anchor">The View to which the popup should be anchored.</param>
public void Show(View anchor)
{
_contextPopup.Show(anchor);
}
+ /// <summary>
+ /// Dismisses the ContextPopup.
+ /// </summary>
public void Dismiss()
{
_contextPopup.Dismiss();
}
+ /// <summary>
+ /// Gets the direction of the ContextPopup if it is shown.
+ /// This method returns false if it is not shown and the output argument is a default value.
+ /// </summary>
+ /// <param name="direction">The direction of the ContextPopup.</param>
+ /// <returns>true if the ContextPopup is shown, false otherwise.</returns>
public bool TryGetContextPopupDirection(out ContextPopupDirection direction)
{
direction = default(ContextPopupDirection);
-namespace Tizen.Xamarin.Forms.Extension
+namespace Tizen.Xamarin.Forms.Extension
{
+ /// <summary>
+ /// The direction priorities of a ContextPopup.
+ /// </summary>
public struct ContextPopupDirectionPriorities
{
+ /// <summary>
+ /// Creates a ContextPopupDirectionPriorities structure.
+ /// </summary>
+ /// <param name="first">The first direction priority.</param>
+ /// <param name="second">The second direction priority.</param>
+ /// <param name="third">The third direction priority.</param>
+ /// <param name="fourth">The fourth direction priority.</param>
public ContextPopupDirectionPriorities(ContextPopupDirection first, ContextPopupDirection second, ContextPopupDirection third, ContextPopupDirection fourth)
{
First = first;
Fourth = fourth;
}
+ /// <summary>
+ /// Gets the first direction priority.
+ /// </summary>
public ContextPopupDirection First { get; private set; }
+
+ /// <summary>
+ /// Gets the second direction priority.
+ /// </summary>
public ContextPopupDirection Second { get; private set; }
+
+ /// <summary>
+ /// Gets the third direction priority.
+ /// </summary>
public ContextPopupDirection Third { get; private set; }
+
+ /// <summary>
+ /// Gets the fourth direction priority.
+ /// </summary>
public ContextPopupDirection Fourth { get; private set; }
}
}
\ No newline at end of file
namespace Tizen.Xamarin.Forms.Extension
{
+ /// <summary>
+ /// The class for the items in a ContextPopup.
+ /// Each item can have a label and an image.
+ /// </summary>
public class ContextPopupItem : INotifyPropertyChanged
{
string _label;
FileImageSource _icon;
+ /// <summary>
+ /// Creates a ContextPopupItem with only a label.
+ /// </summary>
+ /// <param name="label">The label of the ContextPopupItem.</param>
public ContextPopupItem(string label)
{
_label = label;
}
+ /// <summary>
+ /// Creates a ContextPopupItem with a label and icon.
+ /// </summary>
+ /// <param name="label">The label of the ContextPopupItem.</param>
+ /// <param name="icon">The icon of the ContextPopupItem.</param>
public ContextPopupItem(string label, FileImageSource icon)
{
_label = label;
_icon = icon;
}
+ /// <summary>
+ /// Occurs when the label or icon of a ContextPopupItem is changed.
+ /// </summary>
public event PropertyChangedEventHandler PropertyChanged;
+ /// <summary>
+ /// Gets or sets the label of a ContextPopupItem.
+ /// </summary>
public string Label
{
get
}
}
+ /// <summary>
+ /// Gets or sets the icon of a ContextPopupItem.
+ /// </summary>
public FileImageSource Icon
{
get