Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4266192
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T06:43:36+00:00 2026-05-21T06:43:36+00:00

I have a silverlight control that has a Frame on it. I want to

  • 0

I have a silverlight control that has a Frame on it. I want to change the URI of this frame from outside the SL control. (I have an HTML link that will use Javascript to ulimtately tell the SL control to change.) This is all working but I get random JavaScript errors.

Master Page:

<html>
<body>
    <a href="#" onclick="PdmcNav.NavigateTo('page1');">Page 1 Link</a> 
    <a href="#" onclick="PdmcNav.NavigateTo('page2');">Page 2 Link</a> 

    <div id="main" >
        <asp:ContentPlaceHolder ID="MainContent" runat="server">
        </asp:ContentPlaceHolder>
    </div>
</body>
</html>

Included Javascript:

// Defining the namespace object for the Pdmc navigation
var PdmcNav = {};
PdmcNav.PdmcSLControl = null;

PdmcNav.NavigateTo = function (pagename) {

    // check to see if PDMC Silverlight control is on page. if not (is null), then need to load main PDMC page
    if (PdmcNav.PdmcSLControl == null) {
        // handle this later
    } else {
        // Pdmc SL control on page.. 
        // Talk to silverlight control and request it to navigate to pagename
        PdmcNav.PdmcSLControl.Content.PdmcSL.NavigateToPage(pagename);
    }
}

Main Xaml page loaded in master page (MainNavigationView.xaml)

<UserControl x:Class="PDMC.Views.MainNavigationView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:toolkit="clr-namespace:Microsoft.Windows;assembly=System.Windows.Controls.Toolkit"
             xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
             xmlns:navigationCore="clr-namespace:System.Windows.Navigation;assembly=System.Windows.Controls.Navigation"
             mc:Ignorable="d">
    <StackPanel>
        <!-- this is a test of navigation in the control.... works flawlessly -->
        <StackPanel Orientation="Horizontal">
            <HyperlinkButton Content="profile" Margin="4" TargetName="contentFrame" NavigateUri="/Views/SupplierProfile.xaml"/>
            <HyperlinkButton Content="scores" Margin="4" TargetName="contentFrame" NavigateUri="/Views/SupplierScores.xaml"/>
        </StackPanel>
        <navigation:Frame x:Name="contentFrame"
                          Source="/Views/Profile.xaml"
                          VerticalAlignment="Stretch"
                          HorizontalAlignment="Stretch" />
    </StackPanel>
</UserControl>

MainNavigationView.xaml.cs

using System.Windows;
using System.Windows.Controls;
using System.Windows.Browser;
using System;

namespace PDMC.Views {
    public partial class MainNavigationView : UserControl {
        /// <summary>
        /// Initializes a new instance of the MainNavigationView class.
        /// </summary>
        public MainNavigationView() {
            InitializeComponent();

            HtmlPage.RegisterScriptableObject("PdmcSL", this);
        }

        [ScriptableMember]
        public void NavigateToPage(string pageName) {

            if (pageName == "Profile") {
                Uri x = new Uri(@"/Views/Profile.xaml", System.UriKind.RelativeOrAbsolute);
                contentFrame.Source = x;//.Navigate(x);
            } else if (pageName == "Scores") {
                Uri x = new Uri(@"/Views/Scores.xaml", System.UriKind.RelativeOrAbsolute);
                contentFrame.Source=x;//.Navigate(x);
            }
        }
    }
}

I can click on the links in the master page a few times but after several clicks of going back and forth, i get the following error: (its random when i get this)

Message: Unhandled Error in Silverlight Application Content for the URI cannot be loaded. The URI may be invalid.
Parameter name: uri   at System.Windows.Navigation.NavigationService.NavigateCore(Uri uri, NavigationMode mode, Boolean suppressJournalAdd, Boolean isRedirect)
   at System.Windows.Navigation.NavigationService.Journal_Navigated(Object sender, JournalEventArgs args)
   at System.Windows.Navigation.Journal.OnNavigated(String name, Uri uri, NavigationMode mode)
   at System.Windows.Navigation.Journal.UpdateObservables(JournalEntry currentEntry, NavigationMode mode)
   at System.Windows.Navigation.Journal.AddHistoryPoint(JournalEntry journalEntry)
   at System.Windows.Navigation.Journal.AddHistoryPointIfDifferent(String newState)
   at System.Windows.Navigation.Journal.Browser_Navigated(Object sender, EventArgs eventArgs)
   at System.Windows.Navigation.Journal.<>c__DisplayClass3.<InitializeNavigationState>b__2(Object sender, NavigationStateChangedEventArgs args)
   at System.Windows.Interop.SilverlightHost.RaiseNavigationStateChanged(String oldState, String newState)
   at System.Windows.Interop.SilverlightHost.OnNavigationStatePollingTick(Object sender, EventArgs e)
   at MS.Internal.CoreInvokeHandler.InvokeEventHandler(Int32 typeIndex, Delegate handlerDelegate, Object sender, Object args)
   at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, Int32 actualArgsTypeIndex, String eventName)

Anybody see what Im doing wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T06:43:37+00:00Added an answer on May 21, 2026 at 6:43 am

    It appears the solution to my problem is to change my approach. During my research, I discovered that for the Frame element in Main.xaml, the default JournalOwnership is set to Automatic. If I set this to OwnsJournal, the problem goes away. Apparently, if the frame is using the journal of the browser, weird stuff happens if you navigate via a [ScriptableMethod].

    My solution was to change my approach to the problem…. which ends up being more simple and elegant. One thing to note is that when the Journal is managed by the browser (JournalOwnership=Automatic), you can navigate to pages within your control simply using the URL.

    Here’s the solution I ended up with which allows me to have HTML navigation (outside my silverlight control) that will navigate to different pages in my SL control.

    Master Page (Plain Html with links to navigation)

    <html>
    <body>
        <asp:HyperLink ID="HyperLink4" runat="server" NavigateUrl="~/PDMC.aspx#Profiles">Profiles</asp:HyperLink>
        <asp:HyperLink ID="HyperLink2" runat="server" NavigateUrl="~/PDMC.aspx#Scores">Scores</asp:HyperLink>
    </body>
    </html>
    

    Note, the PDMC.aspx is a simple page which contains my silverlight control object.

    Main.xaml is the RootVisual of my silverlight Control. It simply contains a frame which we will use to swap out views:

    <navigation:Page x:Class="PDMC.Views.Main" 
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        mc:Ignorable="d"
        xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
        d:DesignWidth="640" d:DesignHeight="480"
        Title="Main Page">    
            <ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto">
                <StackPanel x:Name="LayoutRoot">
                    <navigation:Frame x:Name="MainFrame" 
                                      Source="/Views/Profile.xaml"
                                      JournalOwnership="Automatic"
                                      UriMapper="{StaticResource PDMC_UriMapper}" />
                </StackPanel>
            </ScrollViewer>
    </navigation:Page>
    

    Finally, to make the external links simpler and prettier, I added a UriMapper to my App.xaml:

    <Application.Resources>
        <navigationCore:UriMapper x:Key="PDMC_UriMapper">
            <navigationCore:UriMapping Uri="Profiles" MappedUri="/Views/Profile.xaml" />
            <navigationCore:UriMapping Uri="Scores" MappedUri="/Views/Scores.xaml" />            
        </navigationCore:UriMapper>
    </Application.Resources>
    

    That’s it.. a much simpler solution.. Hope this helps someone else down the road (and yes Im new to silverlight at time of this discovery 🙂 )

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Silverlight user control that has an Image control within it. This
I have a silverlight control that has a few element such as: Image, TextBox
I have a Silverlight user control that has several canvas controls within a Stack
I have a Silverlight application that has three regions that will host the same
I have a Silverlight control that tries to have the same background as the
I have a control in Silverlight 2 that changes state during the application. When
I have a silverlight control which has a reference to a silverlight enabled wcf
I have created a nice silverlight control doing exactly what I want it to
We have a Silverlight 2 project (game) that will require a lot of character
I have a Silverlight application that is built from a set of Silverlight class

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.