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

  • SEARCH
  • Home
  • 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 730045
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T06:52:01+00:00 2026-05-14T06:52:01+00:00

In my Silverlight app I have an event handler that dynamically creates a new

  • 0

In my Silverlight app I have an event handler that dynamically creates a new instance of a user control and adds it to the Content property of another control. This works just fine without error UNTIL I assign a name (x:Name=””) to the user control (not in the event, but within the XAML of the user control. Then, when I set the template to the .Content property of the control I get a “System.ArgumentException was unhandled by user code / Value does not fall within the expected range.” exception. I have no clue where the error is or where to look… it’s pretty much embedded within SL. Can’t figure out what other property I need to set.

Here’s the code that adds the user control:

TilePane p = e.Element as TilePane; // this is the target
AppTileNormalViewControl template = new AppTileNormalViewControl(); // this is the user control
p.Content = template; // error happens here

The problem here is that the user control has a few public properties that I was going to use for databinding to some of the controls in the user control. I need a name to do the syntax:

Text="{Binding ElementName=UserControlName, Path=PublicProperty}"

Without the ElementName, the binding isn’t working. So, if I specify the name binding will work, but I can’t get the control added. Ideas?

  • 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-14T06:52:01+00:00Added an answer on May 14, 2026 at 6:52 am

    The problem is that the Name property of the UserControl will become part of the set of available element names in scope to which your content control belongs to. As soon as you attempt to add two of these elements in this way you end up trying to add the same name which results in the error you are seeing.

    The name of the UserControl is really the business of the consumer of the usercontrol not the user control itself so you should remove this x:Name. An alternative that does work is like this:-

    Text="{Binding Parent.PublicProperty, ElementName=LayoutRoot}"
    

    A Usercontrol contains a single root element into which you place all of its UI and this element (which is usually a Grid but can actually be any FrameworkElement) is normally names LayoutRoot. A FrameworkElement has a Parent property which in the case of the layout root of a UserControl will the the UserControl itself.

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

Sidebar

Related Questions

For example: First, say I have a Silverlight app with Windowless=true so that I
I have a small Silverlight 4 app that essentially consists of a grid containing
I am using a Silverlight usercontrol in my ASP.NET web app. The user control
I have built a WCF Service that is being consumed by a Silverlight app.
I have a silverlight app that uses WCF both by polling Duplex and normal
I'm writing a Silverlight app using the MVVM pattern. I have a main view
My silverlight app takes the user through a sort of wizard-like process, so for
I'd like to write a Silverlight app that has 2 or more browser windows
I am working on a silverlight app that you need to enter information into
I’m porting a WPF app to silverlight 2, and have come across several WPF

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.