mirror of
https://github.com/Nioux/AideDeJeu.git
synced 2025-10-29 14:35:45 +00:00
Binding compilé sur vue item
This commit is contained in:
parent
35bf6435e9
commit
b151e42240
3 changed files with 41 additions and 23 deletions
|
|
@ -27,7 +27,18 @@ namespace AideDeJeu.ViewModels.Library
|
|||
|
||||
CancellationTokenSource cancellationTokenSource;
|
||||
|
||||
public ItemViewModel(Item item = null)
|
||||
public ItemViewModel()
|
||||
{
|
||||
LoadItemsCommand = new Command(async () => await ExecuteLoadItemsCommandAsync().ConfigureAwait(false));
|
||||
SearchCommand = new Command<string>((text) =>
|
||||
{
|
||||
if (Filter != null)
|
||||
{
|
||||
Filter.SearchText = text;
|
||||
}
|
||||
});
|
||||
}
|
||||
public ItemViewModel(Item item)
|
||||
{
|
||||
Title = item?.Name;
|
||||
Item = item;
|
||||
|
|
|
|||
|
|
@ -3,10 +3,16 @@
|
|||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||
xmlns:tools="clr-namespace:AideDeJeu.Tools"
|
||||
xmlns:mdview="clr-namespace:Xam.Forms.Markdown"
|
||||
xmlns:libvm="clr-namespace:AideDeJeu.ViewModels.Library"
|
||||
xmlns:lib="clr-namespace:AideDeJeuLib"
|
||||
x:Class="AideDeJeu.Views.Library.ItemPage"
|
||||
Title="{Binding Title}"
|
||||
Icon="spell_book.png"
|
||||
x:Name="This">
|
||||
x:Name="This"
|
||||
x:DataType="libvm:ItemViewModel">
|
||||
<ContentPage.BindingContext>
|
||||
<libvm:ItemViewModel />
|
||||
</ContentPage.BindingContext>
|
||||
<ContentPage.Resources>
|
||||
<ResourceDictionary>
|
||||
<tools:MonsterMarkdownTheme x:Key="MonsterMarkdownTheme" />
|
||||
|
|
@ -27,16 +33,16 @@
|
|||
NavigateToLinkCommand="{Binding Main.Navigator.NavigateToLinkCommand}"
|
||||
/>
|
||||
</ScrollView>-->
|
||||
<ListView Grid.Column="0" Grid.Row="0" x:Name="ItemsListView" ItemsSource="{Binding Item.Children}" VerticalOptions="FillAndExpand" HasUnevenRows="true" CachingStrategy="RecycleElement" SelectedItem="{Binding Item.SelectedItem}" ItemTapped="ItemsListView_ItemTapped">
|
||||
<ListView Grid.Column="0" Grid.Row="0" x:Name="ItemsListView" ItemsSource="{Binding Children}" VerticalOptions="FillAndExpand" HasUnevenRows="true" CachingStrategy="RecycleElement" SelectedItem="{Binding SelectedItem}" ItemTapped="ItemsListView_ItemTapped">
|
||||
<ListView.Header>
|
||||
<mdview:MarkdownView
|
||||
Theme="{StaticResource MonsterMarkdownTheme}"
|
||||
Markdown="{Binding Item.Item.Markdown}"
|
||||
Markdown="{Binding Item.Markdown}"
|
||||
NavigateToLinkCommand="{Binding Main.Navigator.NavigateToLinkCommand}"
|
||||
/>
|
||||
</ListView.Header>
|
||||
<ListView.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<DataTemplate x:DataType="lib:Item">
|
||||
<ViewCell>
|
||||
<StackLayout Padding="10" Orientation="Vertical">
|
||||
<Label Text="{Binding Name}" LineBreakMode="WordWrap" TextColor="{StaticResource HDBlue}" Style="{Binding NameLevel,Converter={StaticResource HeaderLevelToStyleConverter}, ConverterParameter=2}" />
|
||||
|
|
|
|||
|
|
@ -20,36 +20,37 @@ namespace AideDeJeu.Views.Library
|
|||
[QueryProperty("Path", "path")]
|
||||
public partial class ItemPage : ContentPage, INotifyPropertyChanged
|
||||
{
|
||||
public MainViewModel Main
|
||||
{
|
||||
get
|
||||
{
|
||||
return DependencyService.Get<MainViewModel>();
|
||||
}
|
||||
}
|
||||
//public MainViewModel Main
|
||||
//{
|
||||
// get
|
||||
// {
|
||||
// return DependencyService.Get<MainViewModel>();
|
||||
// }
|
||||
//}
|
||||
|
||||
private ItemViewModel _Item = new ItemViewModel();
|
||||
//private ItemViewModel _Item = new ItemViewModel();
|
||||
public ItemViewModel Item
|
||||
{
|
||||
get
|
||||
{
|
||||
return _Item;
|
||||
}
|
||||
set
|
||||
{
|
||||
SetProperty(ref _Item, value);
|
||||
return BindingContext as ItemViewModel;
|
||||
//return _Item;
|
||||
}
|
||||
//set
|
||||
//{
|
||||
// SetProperty(ref _Item, value);
|
||||
//}
|
||||
}
|
||||
|
||||
public ItemPage()
|
||||
{
|
||||
BindingContext = this;
|
||||
//BindingContext = this;
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public ItemPage(string id)
|
||||
{
|
||||
BindingContext = this;
|
||||
//BindingContext = this;
|
||||
InitializeComponent();
|
||||
Path = id;
|
||||
//LoadPageAsync();
|
||||
|
|
@ -57,7 +58,7 @@ namespace AideDeJeu.Views.Library
|
|||
|
||||
public ItemPage(ItemViewModel itemViewModel)
|
||||
{
|
||||
BindingContext = this;
|
||||
//BindingContext = this;
|
||||
InitializeComponent();
|
||||
Path = itemViewModel.Item.Id;
|
||||
//Item = itemViewModel;
|
||||
|
|
@ -72,13 +73,13 @@ namespace AideDeJeu.Views.Library
|
|||
protected override void OnAppearing()
|
||||
{
|
||||
base.OnAppearing();
|
||||
Main.CurrentItem = Item;
|
||||
Item.Main.CurrentItem = Item;
|
||||
}
|
||||
|
||||
protected override void OnDisappearing()
|
||||
{
|
||||
base.OnDisappearing();
|
||||
Main.CurrentItem = null;
|
||||
Item.Main.CurrentItem = null;
|
||||
}
|
||||
private string _Path { get; set; } = null; //"index.md";
|
||||
public string Path
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue