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 7496107
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T18:29:01+00:00 2026-05-29T18:29:01+00:00

I have a UserControl with the following Property: public List<Rect> HotSpots { get {

  • 0

I have a UserControl with the following Property:

public List<Rect> HotSpots
{
   get { return (List<Rect>)GetValue(HotSpotsProperty); }
   set { SetValue(HotSpotsProperty, value); }
}

public static readonly DependencyProperty HotSpotsProperty =
        DependencyProperty.Register("HotSpots", typeof(List<Rect>), typeof(ImageViewPort), new FrameworkPropertyMetadata(HotSpotsChanged));

Since compiled XAML (XAML 2006 by default) doesn’t support generics the way the 2009 specification allows, I wonder is there any chance of doing something like the following:

<WPF:ImageViewPort Grid.Row="1">
   <WPF:ImageViewPort.HotSpots>
      <Rect Location="0,0" Height="30" Width="50"></Rect>
       <Rect Location="10,35" Height="30" Width="20"></Rect>
   </WPF:ImageViewPort.HotSpots>
 </WPF:ImageViewPort>

Or is my only chance a Binding like the following?

<WPF:ImageViewPort Grid.Row="1" HotSpots="{Binding Path=HotSpots}"/>

Just out of curiosity, the limitation seems to be XAML’s support for generics, so writing a List derivate should do the trick, shouldn’t it?

  • 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-29T18:29:10+00:00Added an answer on May 29, 2026 at 6:29 pm

    Since XAML isn’t used to add to Collections but rather to setting them, I’ve had to create a wrapping XAML Node that initializes the Collection. Since the Collection is generic, I can’t do this as it is, but have to create a wrapper like so :

    public class HotSpotList : List<Rect> {}
    

    In my XAML then, I can set it like so:

    <WPF:ImageViewPort.HotSpots>
      <HotSpotList>
       <Rect Location="0,0" Height="30" Width="50"></Rect>
       <Rect Location="10,35" Height="30" Width="20"></Rect>
      </HotSpotList>
    </WPF:ImageViewPort.HotSpots>
    

    Easy enough, once you’ve seen it work =)

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

Sidebar

Related Questions

I have following user control: <UserControl.Resources> <Style TargetType=HeaderedItemsControl> <Setter Property=Template> <Setter.Value> <ControlTemplate TargetType=HeaderedItemsControl> <Grid>
I have a UserControl called 'Inspirations' with the following public property private int pagenumber;
I have the following property Temp2 : (my UserControl implements INotifyPropertyChanged) ObservableCollection<Person> _Temp2; public
I have the following code: public partial class queryTerm : System.Web.UI.UserControl { private static
I Have A wpf UserControl with a property: private IEnumerable<PropertyBase> properties; public IEnumerable<PropertyBase> Properties
In out program, we have the following class hierarchy: public class PagePanelBase: UserControl public
I have defined the following select list: <%= this.Select(Scope) .Options(Scopes.AllValues) // static property to
I've created a UserControl with the following public property: [Browsable(true)] public string Text {
I have a UserControl that I've added a Dependency Property to: public partial class
I have a UserControl with a Template property that I've set up as a

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.