Disable UI when showing Winrt progress bar C #

In my winrt C # application, I want to disable user interaction while the progress ring is showing and something is running in the background.

Please let me know how we can achieve this.

Thank.

+3


source to share


2 answers


Place the content inside a grid with one row and column, and put the content inside that separate cell (most likely inside another grid). Within the contained grid, directly below the "real" content, but inside the same separate cell, place a transparent dummy grid with full width and full height, the visibility of which is tied to the visibility of the progress ring. With some tweaking, you should be able to get a dummy grid to capture all user input and prevent it from ending up in "real" content. When the visibility of the dummy grid is collapsed (ie when the progress ring is collapsed as well), the "real" content will function as normal.



+1


source


How I did it. I created a custom control called CurtainUserControl with a single grid inside:

    <Grid x:Name="curtainGrid" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
    </Grid>

      

and in the code i can show it



        public void ShowCurtain()
    {
        CurtainUserControl guc = new CurtainUserControl();
        mainGrid.Children.Add(guc);
    }

      

and hide

        public void HideCurtain()
    {
        int childCount = VisualTreeHelper.GetChildrenCount(mainGrid);
        for (int i = 0; i < childCount; i++)
        {
            CurtainUserControl guc = mainGrid.Children.ElementAt(i) as CurtainUserControl;
            if (guc != null)
            {
                mainGrid.Children.RemoveAt(i);
            }
        }
     }

      

0


source







All Articles