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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:56:56+00:00 2026-05-23T14:56:56+00:00

I have a very strange issue and I have no idea how to debug

  • 0

I have a very strange issue and I have no idea how to debug it. (Side note: I hate creating GUI’s! Anyway… 🙂

I have been following this guide to using drag ‘n drop on Silverlight.
Right now, what I’m interested in is the reordering in a list.

If I follow the example from the site exactly, everything is fine. It works as expected.
But, when I try to substitute the elements for something else, I can no longer reorder?!

Consider the following XAML:

<toolkit:ListBoxDragDropTarget AllowDrop="True">
                <ListBox Width="200" Height="500" x:Name="FromBox" DisplayMemberPath="Label">
                    <ListBox.ItemsPanel>
                        <ItemsPanelTemplate>
                            <StackPanel/>
                        </ItemsPanelTemplate>
                    </ListBox.ItemsPanel>
                </ListBox>
            </toolkit:ListBoxDragDropTarget>

aside from the DisplayMemberPath which is here “Label”, this is the same as in the article I’m following.

In the code-behind I now do the following:

void MainPage_Loaded(object sender, RoutedEventArgs e)
        {
            FromBox.ItemsSource = GetElements();
        }

        public static ObservableCollection<Element> GetElements()
        {
            ObservableCollection<Element> Elements = new ObservableCollection<Element>();
            var Label = new Label();
            Label.Label = "Label me";
            Elements.Add(Label);

            var IntegerBox = new IntegerBox();
            IntegerBox.Label = "Størrelsen på en gennemsnits svale:";
            IntegerBox.Description = "cm";
            Elements.Add(IntegerBox);

            var TextBox = new TextBox();
            TextBox.Label = "QTTextBox";
            Elements.Add(TextBox);

            return Elements;
        }

(Apologies for containing special Danish characters in this bit, but I thought it was better to show the exact code I’m using than editing it out)

As you can see, I return an ObservableCollection of Element’s, each of which has a Label property (and they all inherit from the Element class, obviously).

To me, this ought to work exactly the same as the code provided in the link.
But it doesn’t. It’s as if I can no longer drop items!?

This is how it looks in the article:

alt text

And this is how it looks with my elements:

alt text

Is there some demand on the kind of things that can be reordered? The article uses Person-objects, but these are ultra simple and do not implement any further interfaces. I’m also, as you can see, making sure to use an ObservableCollection with the right type. Is it just because it can’t handle inheritance?!

… Or have I simply been stupid? 🙂

Thanks in advance!

EDIT:
I’ve narrowed down the problem to having to do with inheritance.
The following code cannot be reordered either:

public class People
    {
        public static ObservableCollection<Person> GetListOfPeople()
        {
            ObservableCollection<Person> ppl = new ObservableCollection<Person>();
            for (int i = 0; i < 15; i++)
            {
                if (i % 2 == 0)
                {
                    SomePerson p = new SomePerson() { Firstname = "First " + i.ToString(), Lastname = "Last " + i.ToString() };
                    ppl.Add(p);
                }
                else
                {
                    OtherPerson p = new OtherPerson() {Firstname = "First " + i.ToString(), Lastname = "Last " + i.ToString()};
                    ppl.Add(p);
                }

            }
            return ppl;
        }
    }

    public class Person
    {
        public string Firstname { get; set; }
        public string Lastname { get; set; }
        public string FullName
        {
            get
            {
                return string.Concat(Firstname, " ", Lastname);
            }
        }
    }
    public class SomePerson : Person
    {

    }

    public class OtherPerson : Person
    {

    }

WTF?!
It seems you can only reorder elementes that have the specific type declared as the type-parameter on the ObservableCollection. Thus, if I declare it contains “Person” objects and mix in Person-objects rather than SomePerson and OtherPerson, I can move those.

  • 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-23T14:56:57+00:00Added an answer on May 23, 2026 at 2:56 pm

    I had the same problem and did a bit more digging. Heres my solution: http://cjbhaines.wordpress.com/2011/07/09/silverlight-listboxdragdroptarget-why-cant-i-drop-it-there/

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

Sidebar

Related Questions

I have this very strange issue with my MVC 2 project. Often times, I'll
Very strange issue... I have something like this in my Controller: public ActionResult Initialize(IEnumerable<MyModel>
I have never seen this issue before, its very strange. Just wondering if anyone
I have a very strange issue on my hands. I have two IIS websites
I am facing a very strange issue. I have a SharePoint webpart that displays
I have a very strange issue that I'm hoping someone can help me with.
I have encountered a very strange issue. Whenever I use the .NET membership provider
I have ran into a very strange issue with Google Maps in Chrome 5.0.375.99:
i have encountered a very strange issue: i use json.dump to write a file
Having a very strange issue regarding postback in ASP.NET. I have page dynamically populating

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.