0 Replies - 1225 Views - Last Post: 23 October 2015 - 02:02 AM

#1 masterapi   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 04-February 11

WPF Nested Frames Not Loading Content

Posted 23 October 2015 - 02:02 AM

I'm having an issue with nested frames in a WPF application. An illustration of my issue is attached.

Attached Image

I navigate to several different pages in the main frame. Each time I navigate to a pages 1 and 3 I reference them as new pages. I keep using the same instance of page 2, which is the default page the main frame navigates to on load. Page 2 has a tab control and the content of each tab item is set to a frame that navigates to sub page 1. Sub page 1 also has a tab control and the content of those tab items are set to an second sub page. I'm using RoutedCommands to add/delete tab items and navigate their content to the new frame.

Here's the issue, when the application first loads I can add tab items on tab control 2 and sub frame 2 loads the content as intended. If I navigate to pages 1 or 3 and come back to 2, when I click to add a tab item on tab control 2, the RoutedCommand fires and adds the tab item but the frame has no content. It will continue to have no content for each tab item I add unless I delete its parent and start over on the page.

Something else is also throwing me off. I added a message box to help troubleshoot the frame content issue in the RoutedCommand. If I leave the message box in there then that frame loads as it should after the message box pops up.

Here's a sample of the code as well:

    
    Public Shared Property cmdAddTab As New RoutedCommand()
    Public cbAddTab As New CommandBinding(cmdAddTab, AddressOf AddTabExecuted, AddressOf AddTabCanExecute)

    Private Sub AddTabCanExecute(sender As Object, e As CanExecuteRoutedEventArgs)
        e.CanExecute = True
        e.Handled = True
    End Sub

    Private Sub AddTabExecuted(sender As Object, e As ExecutedRoutedEventArgs)

        Dim tiTemp As New TabItem
        tiTemp.Header = "Tab " + (tabSub2.Items.Count + 1).ToString

        Dim frmTemp As New Frame
        frmTemp.Navigate(New pgSub2)

        tiTemp.Content = frmTemp
        tabSub2.Items.Add(tiTemp)
        tabSub2.SelectedIndex = tabSub2.Items.Count - 1

        e.Handled = True

    End Sub



Any help is GREATLY appreciated!

Is This A Good Question/Topic? 0
  • +

Page 1 of 1