Example #1
0
 private void OnLoaded(object sender, RoutedEventArgs e)
 {
     // if DataContext is null this does nothing (so it's safe)
     DialogParticipation.SetRegister(this, DataContext);
     NavigationService.Navigating += OnNavigating;
     _cachedService = NavigationService;
     DoLoad();
 }
        public AccountOpenView()
        {
            InitializeComponent();

            DataContextChanged += (sender, args) =>
            {
                DialogParticipation.SetRegister(this, this.DataContext);
            };
        }
Example #3
0
        public MainWindow()
        {
            InitializeComponent();

            Loaded += (sender, e) =>
            {
                DialogParticipation.SetRegister(this, this.DataContext);
            };
            Unloaded += (sender, e) =>
            {
                DialogParticipation.SetRegister(this, null);
            };
        }
        public FoodRequestView()
        {
            InitializeComponent();

            DataContextChanged += (sender, args) =>
            {
                DialogParticipation.SetRegister(this, this.DataContext);
            };

            DataContextChanged += (sender, args) =>
            {
                (this.DataContext as FoodRequestViewModel).Model.ReloadItems();
            };
        }
 public LastPageView()
 {
     InitializeComponent();
     this.Loaded += (sender, args) =>
     {
         DialogParticipation.SetRegister(this, this.DataContext);
         ((IWizardPageLoadableViewModel)this.DataContext).LoadedCommand.Execute(this);
     };
     // if using DialogParticipation on Windows which open / close frequently you will get a
     // memory leak unless you unregister.  The easiest way to do this is in your Closing/ Unloaded
     // event, as so:
     //
     // DialogParticipation.SetRegister(this, null);
     this.Unloaded += (sender, args) => { DialogParticipation.SetRegister(this, null); };
 }
        private async Task RunGenerator(int index)
        {
            DependencyObject registration = null;

            if (_treeGeneratorWindow == null)
            {
                registration = DialogParticipation.GetAssociation(this);
                DialogParticipation.SetRegister(registration, _treeGeneratorViewModel);
            }
            var generator = _treeGeneratorViewModel.Tabs[index];
            await _treeGeneratorViewModel.RunAsync(generator);

            if (registration != null)
            {
                DialogParticipation.SetRegister(registration, this);
            }
        }
Example #7
0
        /// <summary>Constructor.</summary>
        public RotarySwitchMappingControl()
        {
            InitializeComponent();

            // TODO I'm sure this isn't the best way. DataContext is null after InitializeComponent() so handle its changed event.
            DataContextChanged +=
                (object sender, DependencyPropertyChangedEventArgs e) =>
            {
                m_rotarySwitchMapping = (DeviceInstance.Settings.RotarySwitchMapping)DataContext;

                if (m_rotarySwitchMapping != null)
                {
                    // TODO ditto. Using dialog:DialogParticipation.Register="{Binding}" in the xaml doesn't work, presumably
                    // because {Binding} resolves to null at that point.
                    DialogParticipation.SetRegister(this, this);
                }
            };
        }
Example #8
0
        private Shell(ShellViewModel viewModel)
        {
            InitializeComponent();
            ViewModel = viewModel;
            DialogParticipation.SetRegister(this, ViewModel);
            this.WhenActivated(d =>
            {
                this.BindCommand(ViewModel, vm => vm.TestCommand, v => v.MenuItem_Test).DisposeWith(d);
                this.OneWayBind(ViewModel, vm => vm.TestName, v => v.TextBox_Test.Text).DisposeWith(d);

                this.BindCommand(ViewModel, vm => vm.LoadFileCommand, v => v.MenuItem_LoadFile).DisposeWith(d);
                this.BindCommand(ViewModel, vm => vm.UpCommand, v => v.Button_Up).DisposeWith(d);
                this.BindCommand(ViewModel, vm => vm.CreateNodeCommand, v => v.MenuItem_CreateNode).DisposeWith(d);
                this.OneWayBind(ViewModel, vm => vm.HasFile, v => v.Grid_Content.Visibility).DisposeWith(d);
                this.OneWayBind(ViewModel, vm => vm.NodeNames, v => v.ListBox_Nodes.ItemsSource).DisposeWith(d);
                this.Bind(ViewModel, vm => vm.SelectedNodeIndex, v => v.ListBox_Nodes.SelectedIndex).DisposeWith(d);
                this.OneWayBind(ViewModel, vm => vm.ItemViewModels, v => v.ListBox_BrowseItems.ItemsSource).DisposeWith(d);
                this.Bind(ViewModel, vm => vm.SelectedItemIndex, v => v.ListBox_BrowseItems.SelectedIndex).DisposeWith(d);
                this.BindCommand(ViewModel, vm => vm.SaveCommand, v => v.KeyBinding_Save).DisposeWith(d);
            });
        }
Example #9
0
 private void OnUnloaded(object sender, RoutedEventArgs e)
 {
     DialogParticipation.SetRegister(this, null);
     _cachedService.Navigating -= OnNavigating;
     DoUnLoad();
 }
 public MetroDialogWindow(IDialogCoordinator coordinator)
 {
     DialogParticipation.SetRegister(this, this);
 }
Example #11
0
 /// <summary>
 /// If using DialogParticipation on Windows which open / close frequently you will get a
 /// memory leak unless you unregister.  The easiest way to do this is in your Closing/ Unloaded event
 /// </summary>
 /// <param name="sender">Source of the event.</param>
 /// <param name="e">     Routed event information.</param>
 private void Shell_OnUnloaded(object sender, RoutedEventArgs e) => DialogParticipation.SetRegister(this, null);
Example #12
0
 public MainWindow()
 {
     InitializeComponent();
     DialogParticipation.SetRegister(this, this);
     _dialogCoordinator = DialogCoordinator.Instance;
 }