Call a page function from usercontrol code

I'm developing a C# and WPF app. I have a WPF Page 'HomeView' with a UserControl 'CreateItem'. After I click a Button (which related function is Close()) inside the UserControl, I have to make the UserControl visibility collapsed and call a function 'ReloadAnalytics' in the Page code.

namespace iMP
{
    public partial class CreateItem : UserControl
    {

    public CreateItem()
    {
        InitializeComponent();
    }

    private void Close(object sender, RoutedEventArgs e)
    {
        HomeView objHomeView= new HomeView();
        objHomeView.CreateNewItemDisplayGrid.Visibility = Visibility.Collapsed;
        objHomeView.InitializeAnalyticsOverview();
    }
}

When I call this function, pressing the Button, nothing happens. (CreateNewItemDisplayGrid is the name of the UserControl in HomeView) (HomeView namespace is iMP.Views and the public partial class is HomeView : Page)



Read more here: https://stackoverflow.com/questions/66267969/call-a-page-function-from-usercontrol-code

Content Attribution

This content was originally published by Gioele Allievi at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: