0

I have created metro apps and I have already created view base for my view like this

public class ViewBase : Page,IView
    {
        public object Parameter { get; private set; }
        private ProgressBar _progressRing;

        public ViewBase()
        {
            Parameter = null;
            _progressRing = new ProgressBar
            {
                IsIndeterminate = true,
                Height = 25,
                Width = 100,
                FlowDirection = FlowDirection.LeftToRight,
                Foreground = new SolidColorBrush(Colors.Blue),
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment = VerticalAlignment.Top,
                Margin = new Thickness(0,12,0,0)
            };
        }

        public ViewBase(object parameter)
        {
            Parameter = parameter;
            _progressRing = new ProgressBar
            {
                IsIndeterminate = true,
                Height = 25,
                Width = 100,
                FlowDirection = FlowDirection.LeftToRight,
                Foreground = new SolidColorBrush(Colors.Blue),
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment = VerticalAlignment.Top,
                Margin = new Thickness(0, 12, 0, 0)
            };
        }

        #region Properties

        public virtual string Title
        {
            get { return ""; }
        }

        #endregion

        #region IView

        public async void DisplayMessage(MessageHandler handler)
        {
            await MessageBoxHelper.ShowAsync(handler);
        }


        public void SetAsBusy()
        {
            _progressRing.Visibility = Visibility.Visible;
            Frame.IsEnabled = false;
        }

        public void SetAsIdle()
        {
            _progressRing.Visibility=Visibility.Collapsed;
            Frame.IsEnabled = true;
        }

        #endregion
    }
}

So now what I need is whenever my view call SetAsBusy() I need to show my progressBar. But it seems I can not add it. Frame.AddChild() is not exist for WinRT API. So how do I do that? I can add progressbar manually in all my view but it will get too much

2
  • You can add it as a Child to some of your controls (like Grid or StackPanel)
    – Filip
    May 31, 2015 at 17:09
  • that means I need to add it in all of my view? I need to do it in my view base so I don't recreate all my ProgressBar
    – albilaga
    May 31, 2015 at 17:41

1 Answer 1

0

"that means I need to add it in all of my view? I need to do it in my view base so I don't recreate all my ProgressBar"

Well by default yes. What you could do is to have a "shell" page around your regular frame, and than set your navigation to interact with that inner frame.

Basic setup you probably want

1
  • How do I can create like that in my ViewBase? I already had that idea but can not find the implementation...
    – albilaga
    Jun 4, 2015 at 2:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.