mirror of
				https://github.com/Nioux/AideDeJeu.git
				synced 2025-10-30 23:16:09 +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; |         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; |             Title = item?.Name; | ||||||
|             Item = item; |             Item = item; | ||||||
|  |  | ||||||
|  | @ -3,10 +3,16 @@ | ||||||
|              xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" |              xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||||||
|              xmlns:tools="clr-namespace:AideDeJeu.Tools" |              xmlns:tools="clr-namespace:AideDeJeu.Tools" | ||||||
|              xmlns:mdview="clr-namespace:Xam.Forms.Markdown" |              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" |              x:Class="AideDeJeu.Views.Library.ItemPage" | ||||||
|              Title="{Binding Title}" |              Title="{Binding Title}" | ||||||
|              Icon="spell_book.png" |              Icon="spell_book.png" | ||||||
|              x:Name="This"> |              x:Name="This" | ||||||
|  |              x:DataType="libvm:ItemViewModel"> | ||||||
|  |     <ContentPage.BindingContext> | ||||||
|  |         <libvm:ItemViewModel /> | ||||||
|  |     </ContentPage.BindingContext> | ||||||
|     <ContentPage.Resources> |     <ContentPage.Resources> | ||||||
|         <ResourceDictionary> |         <ResourceDictionary> | ||||||
|             <tools:MonsterMarkdownTheme x:Key="MonsterMarkdownTheme" /> |             <tools:MonsterMarkdownTheme x:Key="MonsterMarkdownTheme" /> | ||||||
|  | @ -27,16 +33,16 @@ | ||||||
|                 NavigateToLinkCommand="{Binding Main.Navigator.NavigateToLinkCommand}" |                 NavigateToLinkCommand="{Binding Main.Navigator.NavigateToLinkCommand}" | ||||||
|                 /> |                 /> | ||||||
|         </ScrollView>--> |         </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> |             <ListView.Header> | ||||||
|                 <mdview:MarkdownView  |                 <mdview:MarkdownView  | ||||||
|                 Theme="{StaticResource MonsterMarkdownTheme}"  |                 Theme="{StaticResource MonsterMarkdownTheme}"  | ||||||
|                 Markdown="{Binding Item.Item.Markdown}"  |                 Markdown="{Binding Item.Markdown}"  | ||||||
|                 NavigateToLinkCommand="{Binding Main.Navigator.NavigateToLinkCommand}" |                 NavigateToLinkCommand="{Binding Main.Navigator.NavigateToLinkCommand}" | ||||||
|                 /> |                 /> | ||||||
|             </ListView.Header> |             </ListView.Header> | ||||||
|             <ListView.ItemTemplate> |             <ListView.ItemTemplate> | ||||||
|                 <DataTemplate> |                 <DataTemplate x:DataType="lib:Item"> | ||||||
|                     <ViewCell> |                     <ViewCell> | ||||||
|                         <StackLayout Padding="10" Orientation="Vertical"> |                         <StackLayout Padding="10" Orientation="Vertical"> | ||||||
|                             <Label Text="{Binding Name}" LineBreakMode="WordWrap" TextColor="{StaticResource HDBlue}" Style="{Binding NameLevel,Converter={StaticResource HeaderLevelToStyleConverter}, ConverterParameter=2}" /> |                             <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")] |     [QueryProperty("Path", "path")] | ||||||
|     public partial class ItemPage : ContentPage, INotifyPropertyChanged |     public partial class ItemPage : ContentPage, INotifyPropertyChanged | ||||||
|     { |     { | ||||||
|         public MainViewModel Main |         //public MainViewModel Main | ||||||
|         { |         //{ | ||||||
|             get |         //    get | ||||||
|             { |         //    { | ||||||
|                 return DependencyService.Get<MainViewModel>(); |         //        return DependencyService.Get<MainViewModel>(); | ||||||
|             } |         //    } | ||||||
|         } |         //} | ||||||
| 
 | 
 | ||||||
|         private ItemViewModel _Item = new ItemViewModel(); |         //private ItemViewModel _Item = new ItemViewModel(); | ||||||
|         public ItemViewModel Item |         public ItemViewModel Item | ||||||
|         { |         { | ||||||
|             get |             get | ||||||
|             { |             { | ||||||
|                 return _Item; |                 return BindingContext as ItemViewModel; | ||||||
|             } |                 //return _Item; | ||||||
|             set |  | ||||||
|             { |  | ||||||
|                 SetProperty(ref _Item, value); |  | ||||||
|             } |             } | ||||||
|  |             //set | ||||||
|  |             //{ | ||||||
|  |             //    SetProperty(ref _Item, value); | ||||||
|  |             //} | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         public ItemPage() |         public ItemPage() | ||||||
|         { |         { | ||||||
|             BindingContext = this; |             //BindingContext = this; | ||||||
|             InitializeComponent(); |             InitializeComponent(); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         public ItemPage(string id) |         public ItemPage(string id) | ||||||
|         { |         { | ||||||
|             BindingContext = this; |             //BindingContext = this; | ||||||
|             InitializeComponent(); |             InitializeComponent(); | ||||||
|             Path = id; |             Path = id; | ||||||
|             //LoadPageAsync(); |             //LoadPageAsync(); | ||||||
|  | @ -57,7 +58,7 @@ namespace AideDeJeu.Views.Library | ||||||
| 
 | 
 | ||||||
|         public ItemPage(ItemViewModel itemViewModel) |         public ItemPage(ItemViewModel itemViewModel) | ||||||
|         { |         { | ||||||
|             BindingContext = this; |             //BindingContext = this; | ||||||
|             InitializeComponent(); |             InitializeComponent(); | ||||||
|             Path = itemViewModel.Item.Id; |             Path = itemViewModel.Item.Id; | ||||||
|             //Item = itemViewModel; |             //Item = itemViewModel; | ||||||
|  | @ -72,13 +73,13 @@ namespace AideDeJeu.Views.Library | ||||||
|         protected override void OnAppearing() |         protected override void OnAppearing() | ||||||
|         { |         { | ||||||
|             base.OnAppearing(); |             base.OnAppearing(); | ||||||
|             Main.CurrentItem = Item; |             Item.Main.CurrentItem = Item; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         protected override void OnDisappearing() |         protected override void OnDisappearing() | ||||||
|         { |         { | ||||||
|             base.OnDisappearing(); |             base.OnDisappearing(); | ||||||
|             Main.CurrentItem = null; |             Item.Main.CurrentItem = null; | ||||||
|         } |         } | ||||||
|         private string _Path { get; set; } = null; //"index.md"; |         private string _Path { get; set; } = null; //"index.md"; | ||||||
|         public string Path |         public string Path | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Yan Maniez
						Yan Maniez