We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Accessing UserControl Views from within MainWindow.cs

Thread ID:





117037 Jul 25,2014 08:24 PM UTC Aug 4,2014 12:31 PM UTC WPF 2
Tags: TabControlExt
Nick Posey
Asked On July 25, 2014 08:24 PM UTC

I'm new to WPF so bear with me if it's something really obvious but... I am using something similar to your Lazy Loading Demo. My tab control is located in MainWindow.xaml and it contains a few views (user controls) within the XAML as well.  I want to know if there's a way to access the public methods on the views from the MainWindow form? Basically what I'm trying to accomplish is to refresh a grid on the corresponding view once the user clicks on the tab. Since the view is already loaded, I can't use the view's Loaded event nor its constructor and since it's technically visible, I can't use the IsVisibleChanged event so I wanted to try and use the TabControl's SelectedIndexChanged event to figure out which tab was clicked, and then call the corresponding view's Refresh() method.

My relevant MainWindow.xaml Code is:

        <syncfusion:TabControlExt IsLazyLoaded="True" x:Name="TabControl" SelectedIndexChanged="TabControl_SelectedIndexChanged">
            <syncfusion:TabItemExt x:Name="CurrentVisitorsButton" Header="Current Visitors" Height="27">
            <syncfusion:TabItemExt x:Name="VisitorHistoryButton" Header="Visitor History">
            <syncfusion:TabItemExt Header="Visitor Details"/>

Thanks for any help!

Muthukumar A [Syncfusion]
Replied On August 4, 2014 06:12 AM UTC

Hi Nick,

We have created a sample which tries to meet your requirement. Please have it from below location.
In this sample we have used to SelectedItemChanged event of TabControlExt to determine the Selected UserControl and the relevant method get called using reflection.

Muthukumar A



Attachment: TabControl_127811649709340_a4f3e8cd.zip

Nick Posey
Replied On August 4, 2014 12:31 PM UTC

Thanks, that worked perfectly!


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

or the page will be automatically redirected to sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon