mirror of
https://github.com/Nioux/AideDeJeu.git
synced 2025-10-29 14:35:45 +00:00
Passage en binding du selected item + nettoyage de code
This commit is contained in:
parent
07e3b708fa
commit
da08a4d387
3 changed files with 29 additions and 95 deletions
|
|
@ -48,6 +48,20 @@ namespace AideDeJeu.ViewModels
|
|||
}
|
||||
public ObservableCollection<Item> Items { get; private set; } = new ObservableCollection<Item>();
|
||||
|
||||
private Item _SelectedItem;
|
||||
public Item SelectedItem
|
||||
{
|
||||
get
|
||||
{
|
||||
return _SelectedItem;
|
||||
}
|
||||
set
|
||||
{
|
||||
SetProperty(ref _SelectedItem, value);
|
||||
GotoItemCommand.Execute(_SelectedItem);
|
||||
}
|
||||
}
|
||||
|
||||
public Command LoadItemsCommand { get; private set; }
|
||||
public Command<Item> GotoItemCommand { get; private set; }
|
||||
|
||||
|
|
|
|||
|
|
@ -2,12 +2,11 @@
|
|||
<MasterDetailPage xmlns="http://xamarin.com/schemas/2014/forms"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||
xmlns:local="clr-namespace:AideDeJeu.Views"
|
||||
xmlns:tools="clr-namespace:AideDeJeu.Tools"
|
||||
xmlns:tools="clr-namespace:AideDeJeu.Tools"
|
||||
x:Class="AideDeJeu.Views.MainPage"
|
||||
x:Name="This"
|
||||
x:Name="This"
|
||||
IsPresented="False"
|
||||
Title="{Binding ItemsType,Converter={StaticResource ItemTypeToStringConverter}}"
|
||||
>
|
||||
Title="{Binding ItemsType,Converter={StaticResource ItemTypeToStringConverter}}">
|
||||
<MasterDetailPage.Resources>
|
||||
<ResourceDictionary>
|
||||
<ControlTemplate x:Key="SpellsMasterDataTemplate">
|
||||
|
|
@ -80,7 +79,6 @@
|
|||
<MasterDetailPage.Master>
|
||||
<ContentPage Title=" ">
|
||||
<ContentView ControlTemplate="{Binding ItemsType, Converter={StaticResource ItemsTypeTemplateConverter}}" BindingContext="{Binding}" />
|
||||
<!--<ContentView ControlTemplate="{StaticResource SpellsMasterDataTemplate}" BindingContext="{Binding}" />-->
|
||||
</ContentPage>
|
||||
</MasterDetailPage.Master>
|
||||
<MasterDetailPage.Detail>
|
||||
|
|
@ -89,20 +87,6 @@
|
|||
<ToolbarItem Name="Spells" Text="Sorts" Order="Primary" Icon="spell_book.png" Command="{Binding SwitchToSpells}" />
|
||||
<ToolbarItem Name="Monsters" Text="Monstres" Order="Primary" Icon="dragon_head.png" Command="{Binding SwitchToMonsters}" />
|
||||
<ToolbarItem Name="About" Text="À propos de..." Order="Primary" Icon="wooden_sign.png" Command="{Binding AboutCommand}" />
|
||||
<!--<ToolbarItem Name="Home" Text="Accueil" Order="Primary" Icon="ic_home.png" Command="{Binding OpenUrl}" CommandParameter="http://www.pathfinder-fr.org/" />
|
||||
<ToolbarItem Name="Spells" Text="Sorts" Order="Primary" Icon="ic_home.png" Command="{Binding OpenUrl}" CommandParameter="http://www.pathfinder-fr.org/" />-->
|
||||
<!--<ToolbarItem Name="Blog" Text="Blog" Order="Primary" Icon="ic_blog.png" Command="{Binding OpenUrl}" CommandParameter="http://www.pathfinder-fr.org/Blog/" />
|
||||
<ToolbarItem Name="Wikis" Text="Wikis" Order="Primary" Icon="ic_wikis.png" Command="{Binding OpenUrl}" CommandParameter="http://www.pathfinder-fr.org/Wiki/" />
|
||||
<ToolbarItem Name="Forum" Text="Forum" Order="Primary" Icon="ic_forum.png" Command="{Binding OpenUrl}" CommandParameter="http://www.pathfinder-fr.org/Forum/" />
|
||||
|
||||
<ToolbarItem Name="Gallery2" Text="Galerie" Order="Secondary" Icon="ic_gallery.png" Command="{Binding OpenUrl}" CommandParameter="http://www.pathfinder-fr.org/Media/" />
|
||||
<ToolbarItem Name="Plays2" Text="Parties" Order="Secondary" Icon="ic_plays.png" Command="{Binding OpenUrl}" CommandParameter="http://www.pathfinder-fr.org/Wiki/Parties.MainPage.ashx" />
|
||||
<ToolbarItem Name="Search2" Text="Rechercher" Order="Secondary" Icon="ic_search.png" Command="{Binding OpenUrl}" CommandParameter="http://www.pathfinder-fr.org/search/default.aspx" />-->
|
||||
<!--<ToolbarItem Text="Profil" Order="Secondary" Command="{Binding OpenUrl}" CommandParameter="http://www.pathfinder-fr.org/forum/yaf_cp_profile.aspx" />
|
||||
<ToolbarItem Text="Messages privés" Order="Secondary" Command="{Binding OpenUrl}" CommandParameter="http://www.pathfinder-fr.org/forum/default.aspx?g=cp_pm" />
|
||||
<ToolbarItem Text="Connexion" Order="Secondary" Command="{Binding OpenUrl}" CommandParameter="http://www.pathfinder-fr.org/members/login.aspx" />
|
||||
<ToolbarItem Text="Déconnexion" Order="Secondary" Command="{Binding OpenUrl}" CommandParameter="http://www.pathfinder-fr.org/members/logout.aspx" />
|
||||
<ToolbarItem Text="Inscription" Order="Secondary" Command="{Binding OpenUrl}" CommandParameter="http://www.pathfinder-fr.org/members/register.aspx" />-->
|
||||
</ContentPage.ToolbarItems>
|
||||
<StackLayout Orientation="Vertical">
|
||||
<SearchBar x:Name="SearchBar" SearchCommand="{Binding SearchCommand}" SearchCommandParameter="{Binding Text, Source={x:Reference SearchBar}}">
|
||||
|
|
@ -110,65 +94,30 @@
|
|||
<tools:TextChangedBehavior />
|
||||
</SearchBar.Behaviors>
|
||||
</SearchBar>
|
||||
|
||||
|
||||
<ListView x:Name="ItemsListView"
|
||||
ItemsSource="{Binding Items}"
|
||||
VerticalOptions="FillAndExpand"
|
||||
HasUnevenRows="true"
|
||||
RefreshCommand="{Binding LoadItemsCommand}"
|
||||
IsPullToRefreshEnabled="true"
|
||||
IsRefreshing="{Binding IsBusy, Mode=OneWay}"
|
||||
CachingStrategy="RecycleElement"
|
||||
ItemSelected="OnItemSelected">
|
||||
ItemsSource="{Binding Items}"
|
||||
VerticalOptions="FillAndExpand"
|
||||
HasUnevenRows="true"
|
||||
RefreshCommand="{Binding LoadItemsCommand}"
|
||||
IsPullToRefreshEnabled="true"
|
||||
IsRefreshing="{Binding IsBusy, Mode=OneWay}"
|
||||
CachingStrategy="RecycleElement"
|
||||
SelectedItem="{Binding SelectedItem}">
|
||||
<ListView.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<ViewCell>
|
||||
<StackLayout Padding="10">
|
||||
<Label Text="{Binding NamePHB}"
|
||||
LineBreakMode="NoWrap"
|
||||
Style="{DynamicResource subsubsection}"
|
||||
FontSize="16" />
|
||||
<!--<Label Text="{Binding Description}"
|
||||
LineBreakMode="NoWrap"
|
||||
Style="{DynamicResource ListItemDetailTextStyle}"
|
||||
FontSize="13" />-->
|
||||
LineBreakMode="NoWrap"
|
||||
Style="{DynamicResource subsubsection}"
|
||||
FontSize="16" />
|
||||
</StackLayout>
|
||||
</ViewCell>
|
||||
</DataTemplate>
|
||||
</ListView.ItemTemplate>
|
||||
</ListView>
|
||||
<!--<WebView x:Name="MainView" VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand" Navigating="OnNavigating" Source="{Binding Source}" />-->
|
||||
<!--<ActivityIndicator x:Name="aiProgress" Color="Black" IsRunning="True" IsVisible="True" />-->
|
||||
</StackLayout>
|
||||
</ContentPage>
|
||||
</MasterDetailPage.Detail>
|
||||
</MasterDetailPage>
|
||||
|
||||
<!--<TabbedPage xmlns="http://xamarin.com/schemas/2014/forms"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||
xmlns:views="clr-namespace:AideDeJeu.Views"
|
||||
x:Class="AideDeJeu.Views.MainPage">
|
||||
<TabbedPage.Children>
|
||||
<NavigationPage Title="Browse">
|
||||
<NavigationPage.Icon>
|
||||
<OnPlatform x:TypeArguments="FileImageSource">
|
||||
<On Platform="iOS" Value="tab_feed.png"/>
|
||||
</OnPlatform>
|
||||
</NavigationPage.Icon>
|
||||
<x:Arguments>
|
||||
<views:ItemsPage />
|
||||
</x:Arguments>
|
||||
</NavigationPage>
|
||||
|
||||
<NavigationPage Title="About">
|
||||
<NavigationPage.Icon>
|
||||
<OnPlatform x:TypeArguments="FileImageSource">
|
||||
<On Platform="iOS" Value="tab_about.png"/>
|
||||
</OnPlatform>
|
||||
</NavigationPage.Icon>
|
||||
<x:Arguments>
|
||||
<views:AboutPage />
|
||||
</x:Arguments>
|
||||
</NavigationPage>
|
||||
</TabbedPage.Children>
|
||||
</TabbedPage>-->
|
||||
|
|
@ -27,35 +27,6 @@ namespace AideDeJeu.Views
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
async void OnItemSelected(object sender, SelectedItemChangedEventArgs args)
|
||||
{
|
||||
viewModel.GotoItemCommand.Execute(args.SelectedItem);
|
||||
//if (args.SelectedItem is Spell)
|
||||
//{
|
||||
// var item = args.SelectedItem as Spell;
|
||||
// if (item == null)
|
||||
// return;
|
||||
|
||||
// var vm = new SpellDetailViewModel(item);
|
||||
// vm.LoadItemCommand.Execute(null);
|
||||
// await Navigation.PushAsync(new SpellDetailPage(vm));
|
||||
//}
|
||||
//else if (args.SelectedItem is Monster)
|
||||
//{
|
||||
// var item = args.SelectedItem as Monster;
|
||||
// if (item == null)
|
||||
// return;
|
||||
|
||||
// var vm = new MonsterDetailViewModel(item);
|
||||
// vm.LoadItemCommand.Execute(null);
|
||||
// await Navigation.PushAsync(new MonsterDetailPage(vm));
|
||||
//}
|
||||
|
||||
// Manually deselect item.
|
||||
ItemsListView.SelectedItem = null;
|
||||
}
|
||||
|
||||
protected override void OnAppearing()
|
||||
{
|
||||
base.OnAppearing();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue