|
|
|
|
@ -1,4 +1,5 @@
|
|
|
|
|
using BookAStar.Model;
|
|
|
|
|
using BookAStar.Model.Social.Chat;
|
|
|
|
|
using BookAStar.ViewModels.Messaging;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections;
|
|
|
|
|
@ -18,22 +19,36 @@ namespace BookAStar.Views
|
|
|
|
|
"ItemsSource", typeof(ChatUserCollection), typeof(UserListView), default(ChatUserCollection),
|
|
|
|
|
BindingMode.OneWay);
|
|
|
|
|
|
|
|
|
|
public BindableProperty ItemSelectedProperty = BindableProperty.Create(
|
|
|
|
|
"ItemSelected", typeof(ICommand), typeof(UserListView), default(ICommand));
|
|
|
|
|
public BindableProperty ItemSelectedCommandProperty = BindableProperty.Create(
|
|
|
|
|
"ItemSelectedCommand", typeof(ICommand), typeof(UserListView), default(ICommand));
|
|
|
|
|
|
|
|
|
|
public BindableProperty DisableSelectionProperty = BindableProperty.Create(
|
|
|
|
|
"DisableSelection", typeof(bool), typeof(UserListView), false);
|
|
|
|
|
|
|
|
|
|
public BindableProperty HasASelectionProperty = BindableProperty.Create(
|
|
|
|
|
"HasASelection", typeof(bool), typeof(UserListView), false);
|
|
|
|
|
|
|
|
|
|
public BindableProperty SelectedUserProperty = BindableProperty.Create(
|
|
|
|
|
"SelectedUser", typeof(ChatUserInfo), typeof(UserListView), default(ChatUserInfo));
|
|
|
|
|
|
|
|
|
|
public ChatUserCollection ItemsSource
|
|
|
|
|
{
|
|
|
|
|
get { return (ChatUserCollection) GetValue(ItemsSourceProperty); }
|
|
|
|
|
set { SetValue(ItemsSourceProperty, value); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ICommand ItemSelected
|
|
|
|
|
public ChatUserInfo SelectedUser
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return (ChatUserInfo) GetValue(SelectedUserProperty);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ICommand ItemSelectedCommand
|
|
|
|
|
{
|
|
|
|
|
get { return (ICommand) GetValue(ItemSelectedProperty); }
|
|
|
|
|
set { SetValue(ItemSelectedProperty, value); }
|
|
|
|
|
get { return (ICommand) GetValue(ItemSelectedCommandProperty); }
|
|
|
|
|
set { SetValue(ItemSelectedCommandProperty, value); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool DisableSelection
|
|
|
|
|
@ -42,12 +57,18 @@ namespace BookAStar.Views
|
|
|
|
|
set { SetValue(DisableSelectionProperty, value); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool HasASelection
|
|
|
|
|
{
|
|
|
|
|
get { return (bool)GetValue(HasASelectionProperty); }
|
|
|
|
|
set { SetValue(HasASelectionProperty, value); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public UserListView()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
list.ItemSelected += OnUserSelected;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void OnBindingContextChanged()
|
|
|
|
|
{
|
|
|
|
|
base.OnBindingContextChanged();
|
|
|
|
|
@ -58,14 +79,19 @@ namespace BookAStar.Views
|
|
|
|
|
list.EndRefresh();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void OnUserSelected(object sender, SelectedItemChangedEventArgs ev)
|
|
|
|
|
{
|
|
|
|
|
if (ItemSelected != null)
|
|
|
|
|
if (ItemSelected.CanExecute(ev.SelectedItem))
|
|
|
|
|
if (ItemSelectedCommand != null)
|
|
|
|
|
if (ItemSelectedCommand.CanExecute(ev.SelectedItem))
|
|
|
|
|
{
|
|
|
|
|
ItemSelected.Execute(ev.SelectedItem);
|
|
|
|
|
ItemSelectedCommand.Execute(ev.SelectedItem);
|
|
|
|
|
}
|
|
|
|
|
if (DisableSelection) list.SelectedItem = null;
|
|
|
|
|
if (DisableSelection)
|
|
|
|
|
list.SelectedItem = null;
|
|
|
|
|
SetValue(SelectedUserProperty, list.SelectedItem);
|
|
|
|
|
HasASelection = list.SelectedItem != null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|