The following forum(s) are migrating to a new home on Microsoft Q&A (Preview): Developing Universal Windows apps!

Ask new questions on Microsoft Q&A (Preview).
Interact with existing posts until December 13, 2019, after which content will be closed to all new and existing posts.

Learn More

 none
State lost when reparenting UIElement RRS feed

  • Question

  • I am currently developing a framework which lets you write an extension in HTML/JS and that is rendered natively in UWP. I was facing an issue while supporting overflow property. What I want to achieve is, as long as content size is smaller than the container size, no scrollview should be created but when it overflows, I create a scrollview and move all the views from the outer container inside the scrollview.

    Now while doing this, if the control was focused earlier before reparenting, it loses focus after this operation. There can be other state related information also which gets lost like the cursor position in text field.

    So is there some way to store the state of control before moving it from one parent to another so that it preserves earlier state automatically?

    Wednesday, September 18, 2019 11:13 AM

Answers

  • Hi,

    If I understand you correctly, you wants to restore the current state of the content after you added a scrollviewer as parent control. I'm sorry to say the currently there is on build in API in UWP could do that. If you want to implement, you will need to save the states you want manually, like save the cursor position. You could save the position in memory or local folder when you need to add the scrollviewer. And manually set the position after that.

    Best regards,

    Roy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by nimitz92 Friday, September 20, 2019 12:03 PM
    Thursday, September 19, 2019 2:37 AM
    Moderator

All replies

  • Hi,

    If I understand you correctly, you wants to restore the current state of the content after you added a scrollviewer as parent control. I'm sorry to say the currently there is on build in API in UWP could do that. If you want to implement, you will need to save the states you want manually, like save the cursor position. You could save the position in memory or local folder when you need to add the scrollviewer. And manually set the position after that.

    Best regards,

    Roy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by nimitz92 Friday, September 20, 2019 12:03 PM
    Thursday, September 19, 2019 2:37 AM
    Moderator
  • Thanks for the prompt reply.
    Friday, September 20, 2019 12:00 PM