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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T01:53:18+00:00 2026-05-30T01:53:18+00:00

I am using RadTreeView from Telerik’s Silverlight RadControls. My XAML for the RadTreeView is

  • 0

I am using RadTreeView from Telerik’s Silverlight RadControls. My XAML for the RadTreeView is below:

       <telerik:RadTreeView x:Name="treeView1" IsDragDropEnabled="True" Margin="0,0,444,0" ItemsSource="{Binding SectionList}">
           <telerik:RadTreeView.ItemTemplate>
                <telerik:HierarchicalDataTemplate x:Name="defaultSectionName" ItemsSource="{Binding Questions, Mode=TwoWay}">
                    <telerik:HierarchicalDataTemplate.ItemTemplate>
                        <DataTemplate>
                            <TextBlock Text="{Binding Question1, Mode=TwoWay}"/>
                        </DataTemplate>
                    </telerik:HierarchicalDataTemplate.ItemTemplate>
                </telerik:HierarchicalDataTemplate>
            </telerik:RadTreeView.ItemTemplate>
        </telerik:RadTreeView>
        <telerik:RadTreeView x:Name="treeView2" IsDragDropEnabled="True" Margin="410,0,0,0" ItemsSource="{Binding SelectedSectionList}" >
            <telerik:RadTreeView.ItemTemplate>
                <telerik:HierarchicalDataTemplate x:Name="SelectedSectionName" ItemsSource="{Binding Questions, Mode=TwoWay}">
                    <telerik:HierarchicalDataTemplate.ItemTemplate>
                        <DataTemplate>
                            <TextBlock Text="{Binding Question1, Mode=TwoWay}"/>
                        </DataTemplate>
                    </telerik:HierarchicalDataTemplate.ItemTemplate>
                </telerik:HierarchicalDataTemplate>
            </telerik:RadTreeView.ItemTemplate>
        </telerik:RadTreeView>

I have fire events like below:

  private void OnDropQuery(object sender, DragDropQueryEventArgs e)
    {

            RadTreeViewItem destinationItem = e.Options.Destination as RadTreeViewItem;
            object source = this.GetItemFromPayload<object>(e.Options.Payload);
            object target = destinationItem != null ? destinationItem.Item : null;
            DropPosition position = destinationItem != null ? destinationItem.DropPosition : DropPosition.Inside;

            if (source != null && target != null)
            {
                Section sourceSection = source as Section;
                Section targetSection = target as Section;
                Question sourceQuestion = source as Question;
                Question targetQuestion = target as Question;

                if (sourceSection != null)
                {
                    e.QueryResult = false;
                    return;
                }

                if (sourceQuestion != null)
                {
                    if (sourceQuestion != null && targetQuestion != null && object.ReferenceEquals(sourceQuestion, targetQuestion))
                    {
                        e.QueryResult = false;
                        return;
                    }

                    if (targetQuestion != null && position == DropPosition.Inside)
                    {
                        e.QueryResult = false;
                        return;
                    }

                    if (position != DropPosition.Inside && targetQuestion == null)
                    {
                        e.QueryResult = false;
                        return;
                    }
                }
            }
            else
            {
                e.QueryResult = false;
                return;
            }
            e.QueryResult = true;

    }

    private T GetItemFromPayload<T>(object payload)
    {
            IEnumerable draggedItems = payload as IEnumerable;
            if (draggedItems != null)
            {
                return draggedItems.OfType<T>().FirstOrDefault();
            }

        return default(T);
    }

But when I am trying to drop Question I get a NullReferenceException. How do I fix this problem?

  • 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-30T01:53:18+00:00Added an answer on May 30, 2026 at 1:53 am

    I solved it. I just put this code in try catch block and changed the code:

    if (sourceQuestion != null && targetQuestion != null && object.ReferenceEquals(sourceQuestion, targetQuestion))
                        {
                            sourceSection.Questions.Remove(sourceQuestion);
                            targetSection.Questions.Add(sourceQuestion);
                            e.QueryResult = false;
                            return;
                        }
    

    This is it. It is working.

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

Sidebar

Related Questions

I'm using the ContextMenu control from the Silverlight Toolkit, and I'd like to define
I am using MVVM for a WPF app and I have a Telerik RadTreeView,
I am currently using a RadTreeView and just switched over to using Load-On-Demand (ServerSideCallback)
I'm using a RadTreeView to display some data and I need to be able
Using jQuery, how do I get the value from a textbox and then load
Using preview 4 of ASP.NET MVC Code like: <%= Html.CheckBox( myCheckBox, Click Here, True,
In a Telerik RadTreeView has anyone ever been able to display multiple images on
I am using the webservice method of populating my radtreeview as it was described
Using the http://www.ifans.com/forums/showthread.php?t=132024 post from another question i am allowing the user to enter
Using mercurial, I've run into an odd problem where a line from one committer

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.