I need to make a type of page that has a footer with a button which simply closes (pops) the current page. I have implemented the footer in one page already, which looks like this:
<ContentPage ...>
<Grid RowDefinitions="*,Auto">
<ScrollView Grid.Row="0">
...
</ScrollView>
<Button Grid.Row="1" Style="{StaticResource ButtonConfirm}" Margin="8,4" Text="Close" Clicked="ButtonExit_Clicked"/>
</Grid>
</ContentPage>
However, I do not think that manually implementing that on each page would be the wisest course of action since, if I have to change anything in the footer, I’ll have to do so in every single page that has such footer, therefore I need a solution that allows me to create it once and then reuse it. After some research, I’ve figured that using an application-wide ControlTemplate
would be the way to go. However, there are a few additional things that are required:
- I must be able to hide the footer in some pages when I’m loading the content. Once loading is complete, I hide the loading
VerticalStackLayout
and then I’ll show the page itself with the footer and its content;
As an example, I’ll show what I currently do with said page:
<ContentPage ...>
<StackLayout>
<VerticalStackLayout x:Name="LayoutLoading" VerticalOptions="CenterAndExpand">
<Label Text="Loading data. Please wait."/>
</VerticalStackLayout>
<VerticalStackLayout x:Name="LayoutMain" IsVisible="False">
<!--This is there the content with the footer would be-->
</VerticalStackLayout>
</StackLayout>
</ContentPage>
PS.: I do not know if that’s the most appropriate way to implement a “loading” UI so I’m open to any suggestions in that regard as well.
- I must be able to customize the button’s
OnClicked
event and theStyle
andText
properties. Note that they still should have their original values if not overridden.
Even though I know you can set the ControlTemplate
‘s data through TemplateBinding
, that will not allow me to set a default value to these properties, will it? If so, how can I do that?
Therefore, as of now, I’m at a loss as to how I could implement all of this through a ControlTemplate
. If possible, how can I do all of this?
Thanks in advance!