Esempio n. 1
0
        /// <summary>
        /// Handle the Loaded event of the element to which this view model is attached
        /// in order to enable the attached
        /// view model to bind to properties of the parent element
        /// </summary>
        private static void Element_Loaded(object sender, RoutedEventArgs e)
        {
            FrameworkElement             targetElement = sender as FrameworkElement;
            CircularProgressBarViewModel attachedModel = GetAttach(targetElement);

            // find the ProgressBar and associated it with the view model
            var progressBar = targetElement.Ancestors <ProgressBar>().Single() as ProgressBar;

            attachedModel.SetProgressBar(progressBar);
        }
Esempio n. 2
0
        /// <summary>
        /// Change handler for the Attach property
        /// </summary>
        private static void OnAttachChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            // set the view model as the DataContext for the rest of the template
            FrameworkElement             targetElement = d as FrameworkElement;
            CircularProgressBarViewModel viewModel     = e.NewValue as CircularProgressBarViewModel;

            targetElement.DataContext = viewModel;

            // handle the loaded event
            targetElement.Loaded += new RoutedEventHandler(Element_Loaded);
        }
Esempio n. 3
0
 public static void SetAttach(DependencyObject d, CircularProgressBarViewModel value)
 {
     d.SetValue(AttachProperty, value);
 }
 public static void SetAttach(DependencyObject d, CircularProgressBarViewModel value)
 {
     d.SetValue(AttachProperty, value);
 }