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.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Accessing UserControl Views from within MainWindow.cs

Thread ID:

Created:

Updated:

Platform:

Replies:

117037 Jul 25,2014 08:24 PM UTC Aug 4,2014 12:31 PM UTC WPF 2
loading
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">
                <views:CurrentVisitorsView/>
            </syncfusion:TabItemExt>
            <syncfusion:TabItemExt x:Name="VisitorHistoryButton" Header="Visitor History">
                <views:VisitorHistoryView/>
            </syncfusion:TabItemExt>
            <syncfusion:TabItemExt Header="Visitor Details"/>
        </syncfusion:TabControlExt>



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.

Thanks,
Muthukumar A

 

 


Attachment: TabControl_127811649709340_a4f3e8cd.zip

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

Thanks, that worked perfectly!

CONFIRMATION

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.

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

;