aurora/Aurora/Design/Components/MemberList/MemberList.xaml.cs
watsonb8 823e1341ca First pass at events almost buttoned up.
The goal is to get the members list to update when new users enter and leave the party.
2019-07-07 17:12:13 -04:00

66 lines
2.1 KiB
C#

using System;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using Xamarin.Forms;
using Aurora.Proto.Party;
namespace Aurora.Design.Components.MemberList
{
public partial class MemberList : ContentView
{
private static ObservableCollection<PartyMember> _newSource;
public MemberList()
{
InitializeComponent();
}
/// <summary>
/// Bindable property for members list.
/// </summary>
/// <param name=""Members""></param>
/// <param name="typeof(IEnumerable<string>"></param>
/// <returns></returns>
public static readonly BindableProperty MembersProperty =
BindableProperty.Create(propertyName: "Members",
returnType: typeof(ObservableCollection<PartyMember>),
declaringType: typeof(MemberList),
defaultBindingMode: BindingMode.Default,
propertyChanged: OnMembersChanged);
/// <summary>
/// Backing property for MembersProperty
/// </summary>
/// <value></value>
public ObservableCollection<PartyMember> Members
{
get
{
return (ObservableCollection<PartyMember>)GetValue(MembersProperty);
}
set
{
SetValue(MembersProperty, value);
}
}
/// <summary>
/// Memberes changed event handler. Assign member list source.
/// </summary>
/// <param name="bindable"></param>
/// <param name="oldValue"></param>
/// <param name="newValue"></param>
private static void OnMembersChanged(BindableObject bindable, object oldValue, object newValue)
{
var control = (MemberList)bindable;
var membersList = control.FindByName("MembersHorizontalList") as HorizontalList.HorizontalList;
if (membersList != null)
{
_newSource = newValue as ObservableCollection<PartyMember>;
membersList.ItemsSource = newValue as ObservableCollection<PartyMember>;
}
}
}
}