aurora/Aurora/Design/Components/MemberList/MemberList.xaml.cs

68 lines
2.0 KiB
C#
Raw Normal View History

using System;
2019-07-06 19:52:28 +00:00
using System.Collections.ObjectModel;
using System.Collections.Specialized;
2019-12-23 04:58:29 +00:00
using System.Collections;
using System.Linq;
using Xamarin.Forms;
using Aurora.Proto.Party;
2019-12-23 04:58:29 +00:00
using DLToolkit.Forms.Controls;
2019-07-05 18:17:09 +00:00
namespace Aurora.Design.Components.MemberList
{
public partial class MemberList : ContentView
{
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",
2019-07-06 19:52:28 +00:00
returnType: typeof(ObservableCollection<PartyMember>),
declaringType: typeof(MemberList),
defaultBindingMode: BindingMode.Default,
propertyChanged: OnMembersChanged);
/// <summary>
/// Backing property for MembersProperty
/// </summary>
/// <value></value>
2019-07-06 19:52:28 +00:00
public ObservableCollection<PartyMember> Members
{
get
{
2019-07-06 19:52:28 +00:00
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;
2019-12-23 04:58:29 +00:00
var membersList = control.FindByName("MembersList") as FlowListView;
2019-12-23 04:58:29 +00:00
if (newValue is ICollection source)
{
2019-12-23 04:58:29 +00:00
membersList.FlowItemsSource = source;
}
}
}
}
2019-07-06 19:52:28 +00:00