Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions src/Controls/samples/Controls.Sample/Pages/Base/BasePage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,18 @@ namespace Maui.Controls.Sample.Pages.Base
{
public class BasePage : ContentPage, IPage
{
SectionModel _selectedItem;

public BasePage()
{
NavigateCommand = new Command<SectionModel>(sectionModel =>
NavigateCommand = new Command(async () =>
{
if (sectionModel != null)
Navigation.PushAsync(PreparePage(sectionModel));
if (SelectedItem != null)
{
await Navigation.PushAsync(PreparePage(SelectedItem));

SelectedItem = null;
}
});
}

Expand All @@ -30,6 +36,16 @@ protected override void OnDisappearing()

public ICommand NavigateCommand { get; }

public SectionModel SelectedItem
{
get { return _selectedItem; }
set
{
_selectedItem = value;
OnPropertyChanged();
}
}

Page PreparePage(SectionModel model)
{
var page = (Page)Activator.CreateInstance(model.Type);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@
BackgroundColor="Transparent"
ItemsSource="{Binding FilteredItems}"
SelectionMode="Single"
SelectedItem="{Binding SelectedItem, Source={x:RelativeSource AncestorType={x:Type ContentPage}}, Mode=TwoWay}"
SelectionChangedCommand="{Binding NavigateCommand, Source={x:RelativeSource AncestorType={x:Type ContentPage}}}"
SelectionChangedCommandParameter="{Binding SelectedItem, Source={x:Reference CompatibilitySections}}"
Margin="6, 12, 6, 0">
<CollectionView.ItemsLayout>
<LinearItemsLayout
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@
BackgroundColor="Transparent"
ItemsSource="{Binding FilteredItems}"
SelectionMode="Single"
SelectedItem="{Binding SelectedItem, Source={x:RelativeSource AncestorType={x:Type ContentPage}}, Mode=TwoWay}"
SelectionChangedCommand="{Binding NavigateCommand, Source={x:RelativeSource AncestorType={x:Type ContentPage}}}"
SelectionChangedCommandParameter="{Binding SelectedItem, Source={x:Reference ControlSections}}"
Margin="6, 12, 6, 0">
<CollectionView.ItemsLayout>
<LinearItemsLayout
Expand Down
6 changes: 2 additions & 4 deletions src/Controls/samples/Controls.Sample/Pages/CorePage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@
<controls:BordelessEntry
Grid.Column="1"
Placeholder="Filter"
Text="{Binding FilterValue, Mode=OneWayToSource}"
ReturnCommand="{Binding FilterCommand}"
ReturnType="Search"
Text="{Binding FilterValue, Mode=TwoWay}"
PlaceholderColor="{DynamicResource TextSecondaryColor}"
TextColor="{DynamicResource TextPrimaryColor}"
FontSize="Medium"
Expand All @@ -48,8 +46,8 @@
BackgroundColor="Transparent"
ItemsSource="{Binding FilteredItems}"
SelectionMode="Single"
SelectedItem="{Binding SelectedItem, Source={x:RelativeSource AncestorType={x:Type ContentPage}}, Mode=TwoWay}"
SelectionChangedCommand="{Binding NavigateCommand, Source={x:RelativeSource AncestorType={x:Type ContentPage}}}"
SelectionChangedCommandParameter="{Binding SelectedItem, Source={x:Reference CoreSections}}"
Margin="6, 12, 6, 0">
<CollectionView.ItemsLayout>
<LinearItemsLayout
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@
BackgroundColor="Transparent"
ItemsSource="{Binding FilteredItems}"
SelectionMode="Single"
SelectedItem="{Binding SelectedItem, Source={x:RelativeSource AncestorType={x:Type ContentPage}}, Mode=TwoWay}"
SelectionChangedCommand="{Binding NavigateCommand, Source={x:RelativeSource AncestorType={x:Type ContentPage}}}"
SelectionChangedCommandParameter="{Binding SelectedItem, Source={x:Reference LayoutSections}}"
Margin="6, 12, 6, 0">
<CollectionView.ItemsLayout>
<LinearItemsLayout
Expand Down
5 changes: 3 additions & 2 deletions src/Controls/samples/Controls.Sample/Pages/MainPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,10 @@
x:Name="HomeSections"
BackgroundColor="Transparent"
ItemsSource="{Binding Items}"
SelectionMode="Single"
SelectionMode="Single"
SelectedItem="{Binding SelectedItem, Source={x:RelativeSource AncestorType={x:Type ContentPage}}, Mode=TwoWay}"
SelectionChangedCommand="{Binding NavigateCommand, Source={x:Reference HomePage}}"
SelectionChangedCommandParameter="{Binding SelectedItem, Source={x:Reference HomeSections}}">
Margin="6, 12, 6, 0">
<CollectionView.ItemsLayout>
<GridItemsLayout
Orientation="Vertical"
Expand Down
2 changes: 1 addition & 1 deletion src/Controls/samples/Controls.Sample/Pages/OthersPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@
BackgroundColor="Transparent"
ItemsSource="{Binding FilteredItems}"
SelectionMode="Single"
SelectedItem="{Binding SelectedItem, Source={x:RelativeSource AncestorType={x:Type ContentPage}}, Mode=TwoWay}"
SelectionChangedCommand="{Binding NavigateCommand, Source={x:RelativeSource AncestorType={x:Type ContentPage}}}"
SelectionChangedCommandParameter="{Binding SelectedItem, Source={x:Reference CoreSections}}"
Margin="6, 12, 6, 0">
<CollectionView.ItemsLayout>
<LinearItemsLayout
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@
BackgroundColor="Transparent"
ItemsSource="{Binding FilteredItems}"
SelectionMode="Single"
SelectedItem="{Binding SelectedItem, Source={x:RelativeSource AncestorType={x:Type ContentPage}}, Mode=TwoWay}"
SelectionChangedCommand="{Binding NavigateCommand, Source={x:RelativeSource AncestorType={x:Type ContentPage}}}"
SelectionChangedCommandParameter="{Binding SelectedItem, Source={x:Reference UserInterfaceSections}}"
Margin="6, 12, 6, 0">
<CollectionView.ItemsLayout>
<LinearItemsLayout
Expand Down