46 lines
1.4 KiB
C#
46 lines
1.4 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Collections.ObjectModel;
|
|
using Aurora.Frontend.Views.Components.NavigationMenu;
|
|
using Xamarin.Forms;
|
|
|
|
namespace Aurora.Frontend.Components.NavigationMenu
|
|
{
|
|
public partial class NavigationMenu : ContentPage
|
|
{
|
|
public NavigationMenu()
|
|
{
|
|
InitializeComponent();
|
|
ListView = MenuItemsListView;
|
|
}
|
|
|
|
public ListView ListView;
|
|
|
|
public static readonly BindableProperty ItemsProperty =
|
|
BindableProperty.Create(propertyName: nameof(Items),
|
|
returnType: typeof(ObservableCollection<NavigationItem>),
|
|
declaringType: typeof(NavigationMenu),
|
|
defaultBindingMode: BindingMode.TwoWay,
|
|
propertyChanged: OnItemsChanged);
|
|
|
|
public ObservableCollection<NavigationItem> Items
|
|
{
|
|
get
|
|
{
|
|
return (ObservableCollection<NavigationItem>)GetValue(ItemsProperty);
|
|
}
|
|
set
|
|
{
|
|
SetValue(ItemsProperty, value);
|
|
}
|
|
}
|
|
|
|
private static void OnItemsChanged(BindableObject bindable, object oldValue, object newValue)
|
|
{
|
|
var control = (NavigationMenu)bindable;
|
|
control.MenuItemsListView.ItemsSource = (ObservableCollection<NavigationItem>)newValue;
|
|
}
|
|
|
|
}
|
|
}
|