Showing popup at bottom of the scrollable area

guess_me_if_u_can 126 Reputation points
2021-01-29T08:59:42.647+00:00

61758-image.png

I am showing a button in bottom of a scrollable area. A popup will open on the button click action. If the button locates in the bottom of the scrollable area, then the area below the button is not enough to show the entire popup. in such case, is it possible to extend the scrollable area so that i can scroll to view popup content ?

(PS: in my real case, the button and popup with variable size combined to be a custom templated control. if such control is placed at last of the page, i need to show the popup with extended scroll area or need to show the popup above the button).

Kindly help. Thanks in advance.

Universal Windows Platform (UWP)
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Nico Zhu (Shanghai Wicresoft Co,.Ltd.) 12,866 Reputation points
    2021-02-01T01:23:26.627+00:00

    Hello, Welcome to Micorosoft Q&A,

    Showing popup at bottom of the scrollable area

    You could use TransformToVisual method to get popup's position relative to the scrollviewer, then call ChangeView method after popup displayed.

    private void Button_Click(object sender, RoutedEventArgs e)  
    {  
        popup.IsOpen = true;  
        var ttv = popup.TransformToVisual(MyScollViewer);  
        Point position = ttv.TransformPoint(new Point(0, 0));  
        MyScollViewer.ChangeView(0, position.Y ,1,true);  
    }  
    

    If the response is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.