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. Image for the cookie policy date

How to reference a contentControl (Frame)

I am creating a new tab and document (Frame) upon a button click. In order to prevent multiple of the same window I am trying to check and see if this window already exists by attempting to find it by name, however it can't seem to find it, although it is listed as a Child at runtime.

        private void NewWeighButton_Click(object sender, RoutedEventArgs e)
        {
            //Check if the window is already open, if it is focus it, if not create it.
            if (SyncDockingManager.FindName("NewWeigh") == null)
            {
                Frame newWeighFrame = new Frame();
                newWeighFrame.Content = new SelectACPage(new SelectAircraftViewModel(Context));
                newWeighFrame.Name = "NewWeigh";
                DockingManager.SetHeader(newWeighFrame, "New Weigh");
                DockingManager.SetState(newWeighFrame, DockState.Document);
                DockingManager.SetIsSelectedTab(newWeighFrame, true);
                SyncDockingManager.Children.Add(newWeighFrame);
            }
            else
            {
                SyncDockingManager.FindName("NewWeigh");
            }
        }

2 Replies

DE Dwayne Etchison October 31, 2016 09:08 PM UTC

Disregard, but just to clarify i had to register the name.


DR Durga Rajan Syncfusion Team November 1, 2016 12:02 PM UTC

Hi Dwayne,

We can find the child element from DockingManager by iterating the children collection of DockingManager instead of using FindName method which comes from FrameworkElement. We have prepared the sample to find the existing element by name. In this sample we have FindChild method which returns the child element corresponding to the name of that child. Please download the sample from the below link.

Sample:DockingManager_Sample

Please let us know more details about the requirement if we have misunderstood your query.

Regards,
Durga S.

Loader.
Up arrow icon