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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T17:15:50+00:00 2026-05-20T17:15:50+00:00

I have a datagrid bound to a list of objects. Users can add a

  • 0

I have a datagrid bound to a list of objects. Users can add a new row below where the cursor is ( In code I create a new object and insert it in the list at the appropiate position).

Imagine that the datagrid has 4 rows

If the cursor is positioned in row number 4, then the row gets added, however, if the cursor is position in any of the other rows (1,2 or 3) then I get this exception:

System.Windows.Markup.XamlParseException occurred
Message=”Root element is missing.”
Source=”PresentationFramework”
LineNumber=0
LinePosition=0
StackTrace:
at System.Windows.Markup.XamlReaderHelper.RethrowAsParseException(String keyString, Int32 lineNumber, Int32 linePosition, Exception innerException)
InnerException: System.Xml.XmlException
Message=”Root element is missing.”
Source=”System.Xml”
LineNumber=0
LinePosition=0
SourceUri=””
StackTrace:
at System.Xml.XmlTextReaderImpl.Throw(Exception e)
at System.Xml.XmlTextReaderImpl.ParseDocumentContent()
at System.Windows.Markup.XmlCompatibilityReader.Read()
at System.Windows.Markup.XamlReaderHelper.Read(XamlNode& xamlNode)
InnerException:

NOTE: when the app first loads, if i first add a row (by being in the last row), then i am also able to add a row from any of the other rows. However, if i first try to add a row from row numbers 1,2,3 then it fails!

Any help will be greatly appreciated. I am totally lost. I doubt anyone else has experienced this, but maybe you know what can be causing this or how I could debug it, as I do not know where to start 🙁

        private void OnAddRowBelowCursor(DataGrid datagrid)
    {
        try
        {
            int index = datagrid.SelectedIndex;
            MyObject newObj = new MyObject();
            ObjectList.Insert(index + 1, newObj);
            Logging.log.Info("Appended object row below the cursor...");
        }
        catch (Exception ex)
        {
            Logging.log.Error("Error appending row below cursor. Reason: " + ex.ToString());
        }
    }



    private void OnAppendRowToBottom()
    {
        try
        {
            MyObject newObj = new MyObject();
            ObjectList.Add(newObj);
            Logging.log.Info("Appended object row to bottom...");
        }
        catch (Exception ex)
        {
            Logging.log.Error("Error appending row to the bottom of the table. Reason: " + ex.ToString());
        }
    }

I have also notice that adding a row to the bottom does not fail

Thanks

  • 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-20T17:15:51+00:00Added an answer on May 20, 2026 at 5:15 pm

    I was using the RTB from the extended library with an XAMLFormatter.

    When creating a new row, I wasn’t converting my empty string to XAML fortmat. Why it only fails when I was adding it below the cursor and not at the end, I still do not know. But it is fixed

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

Sidebar

Related Questions

No related questions found

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.