Reputation: 1
I need my flyoutItem to perform a programmatically clicked button click before it performs its AppShell route to the selected page.
(The code for the button works as intended from a legacy project)
I am only currently able to navigate correctly using flyoutitems, and click the button on the activity pages, but can't seem to get the flyoutitem click to load the data on the navigated TO page upon loading.
In this example I can click a button that saves the data and I can click the flyoutitem to navigate, but I want the flyoutitem to click the button and then navigate:
mainpage.xaml.cs
public MainPage()
{
InitializeComponent();
one.Text = Preferences.Get("One", "FIRST");
}
private void savebtnClicked(object sender, EventArgs e)
{
one.Text = j1.Text;
Preferences.Set("One", one.Text);
}
page2.xaml.cs
public page2()
{
InitializeComponent();
tone.Text = Preferences.Get("One", "FIRST");
}
AppShell.xaml
<FlyoutItem
Title="HOME">
<ShellContent
ContentTemplate="{DataTemplate local:MainPage}"
Route="MainPage" />
</FlyoutItem>
<FlyoutItem
Title="TWO">
<ShellContent
ContentTemplate="{DataTemplate local:page2}"
Route="MainPage" />
</FlyoutItem>
mainpage.xaml
<Editor
x:Name="j1"
Placeholder="Empty">
</Editor>
<Label
x:Name="one"
Text=""
FontSize="32"/>
<Button
x:Name="savebtn"
Text="SAVE"
Clicked="savebtnClicked"/>
page2.xaml
<Label
x:Name="tone"
Text=""
FontSize="32"/>
As it is currently, the value passed appears to save, but requires the app to fully restart before it loads in the value that should have been saved to the key "one".
Upvotes: 0
Views: 217
Reputation: 1
UPDATE:
I ended up using "OnAppearing" and then added my loading pref.get's and this worked.
Unfortunately this is just another project that I will not be learning MVVM for even though I badly want to start implementing it.
Upvotes: 0