© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
2 replies
r2d25551

❔ How To Refresh ContentPage Controls

When routing from the MainPage to my details page I pass in:
MyData myData = currentSelectedItems.FirstOrDefault() as MyData;
Dictionary<string, object> navParams = new Dictionary<string, object>
{
   { "MyData", myData }
};

await Shell.Current.GoToAsync($"MyDetailsPage", navParams);
MyData myData = currentSelectedItems.FirstOrDefault() as MyData;
Dictionary<string, object> navParams = new Dictionary<string, object>
{
   { "MyData", myData }
};

await Shell.Current.GoToAsync($"MyDetailsPage", navParams);

The detail page properly receives the passed parameter. But there is caveat. It is not available to OnLoaded is called.
The initial control values are nearly empty, except for DateTime, etc. Also, there are times when the passed parameters are null, and new detail item is being created. The BindingContext is set in the page constructor, and XAML references the x:DataType:

x:DataType="local:MyData"

public MyData myData;

public MyDetailsPage()
{
    InitializeComponent();
    BindingContext = this;
}


protected void OnLoaded(object sender, EventArgs e)
{
    if (myData == null)
    {
        isNew = true;
        myData = new MyData();
        myData.GUID = Guid.NewGuid();
    }
}
x:DataType="local:MyData"

public MyData myData;

public MyDetailsPage()
{
    InitializeComponent();
    BindingContext = this;
}


protected void OnLoaded(object sender, EventArgs e)
{
    if (myData == null)
    {
        isNew = true;
        myData = new MyData();
        myData.GUID = Guid.NewGuid();
    }
}

At this point my controls are blank. How do I ask the page to refresh?
Do I need to do so manually for each control?
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

❔ Generic ContentPage in maui?
C#CC# / help
4y ago
How to test user controls
C#CC# / help
2y ago
MAUI how to make ContentPage and FlyoutPage as one page?
C#CC# / help
3y ago
❔ ✅ How to get ImageLocation from Controls?
C#CC# / help
3y ago