本文整理汇总了C#中GalaSoft.MvvmLight.Helpers.Binding.ForceUpdateValueFromSourceToTarget方法的典型用法代码示例。如果您正苦于以下问题:C# Binding.ForceUpdateValueFromSourceToTarget方法的具体用法?C# Binding.ForceUpdateValueFromSourceToTarget怎么用?C# Binding.ForceUpdateValueFromSourceToTarget使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GalaSoft.MvvmLight.Helpers.Binding
的用法示例。
在下文中一共展示了Binding.ForceUpdateValueFromSourceToTarget方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetupBindings
protected virtual void SetupBindings()
{
_isConnectedBinding = this.SetBinding(() => DeviceVm.IsConnected).WhenSourceChanges(() =>
{
System.Diagnostics.Debug.WriteLine("SubDeviceViewControllerBase: DeviceViewModel PropertyChanged IsConnected");
var navService = ServiceLocator.Current.GetInstance<INavigationService>();
if (!DeviceVm.IsConnected && navService.CurrentPageKey == _viewPageKey)
{
System.Diagnostics.Debug.WriteLine("Navigating back since device is not connected anymore.");
navService.GoBack();
}
});
_isConnectedBinding.ForceUpdateValueFromSourceToTarget();
_programModeBinding = this.SetBinding(() => DeviceVm.ProgramMode).WhenSourceChanges(() =>
{
System.Diagnostics.Debug.WriteLine("SubDeviceViewControllerBase: DeviceViewModel PropertyChanged ProgramMode");
var navService = ServiceLocator.Current.GetInstance<INavigationService>();
if (_programMode != MoCoBusProgramMode.Invalid && DeviceVm.ProgramMode != _programMode && navService.CurrentPageKey == _viewPageKey)
{
System.Diagnostics.Debug.WriteLine("Navigating back since ProgramMode was changed to another mode");
navService.GoBack();
}
});
_programModeBinding.ForceUpdateValueFromSourceToTarget();
}
示例2: OnResume
public override void OnResume()
{
base.OnResume();
System.Diagnostics.Debug.WriteLine("ModeSmsViewFragment OnResume");
_prevRunStatus = MoCoBusRunStatus.Stopped;
_runStatusBinding = this.SetBinding(() => DeviceVm.RunStatus)
.WhenSourceChanges(() =>
{
System.Diagnostics.Debug.WriteLine("ModeSmsViewFragment RunStatus Changed (new={0},prev={1})", DeviceVm.RunStatus, _prevRunStatus);
lock (_runStatusLock)
{
if (DeviceVm.RunStatus != MoCoBusRunStatus.Stopped && DeviceVm.RunStatus != _prevRunStatus && !DeviceVm.IsUpdateTaskRunning)
{
System.Diagnostics.Debug.WriteLine("ModeSmsViewFragment RunStatus Changed: Looking for dialog");
var dlg = FragmentManager.FindFragmentByTag<DialogFragment>(Consts.DialogTag);
if (dlg == null)
{
System.Diagnostics.Debug.WriteLine("ModeSmsViewFragment RunStatus Changed: Create ModeSmsStatusViewFragment");
var ft = FragmentManager.BeginTransaction();
ft.DisallowAddToBackStack();
var dlg2 = ModeSmsStatusViewFragment.NewInstance();
dlg2.Stoped += (oo, ee) => { };
dlg2.Paused += (oo, ee) => { };
dlg2.Resumed += (oo, ee) => { };
dlg2.SetCommand("Stoped", Vm.StopProgramCommand);
dlg2.SetCommand("Paused", Vm.PauseProgramCommand);
dlg2.SetCommand("Resumed", Vm.StartProgramCommand);
dlg2.Show(ft, Consts.DialogTag);
}
DeviceVm.StartUpdateTask();
}
}
_prevRunStatus = DeviceVm.RunStatus;
});
_runStatusBinding.ForceUpdateValueFromSourceToTarget();
_exposureTimeBinding = this.SetBinding(() => Vm.ExposureTime)
.WhenSourceChanges(() =>
{
ExposureTimeEditText.Text = $"{Vm.ExposureTime:F1}s";
});
_exposureTimeBinding.ForceUpdateValueFromSourceToTarget();
_preDelayTimeBinding = this.SetBinding(() => Vm.PreDelayTime)
.WhenSourceChanges(() =>
{
PreDelayTimeEditText.Text = $"{Vm.PreDelayTime:F1}s";
});
_preDelayTimeBinding.ForceUpdateValueFromSourceToTarget();
_delayTimeBinding = this.SetBinding(() => Vm.DelayTime)
.WhenSourceChanges(() =>
{
DelayTimeEditText.Text = $"{Vm.DelayTime:F1}s";
});
_delayTimeBinding.ForceUpdateValueFromSourceToTarget();
_intervalTimeBinding = this.SetBinding(() => Vm.IntervalTime)
.WhenSourceChanges(() =>
{
IntervalTimeEditText.Text = $"{Vm.IntervalTime:F1}s";
});
_intervalTimeBinding.ForceUpdateValueFromSourceToTarget();
_durationTimeBinding = this.SetBinding(() => Vm.DurationTime)
.WhenSourceChanges(() =>
{
DurationTimeEditText.Text = $"{(int)(Vm.DurationTime / 60)}:{(int)Vm.DurationTime % 60:00}m";
});
_durationTimeBinding.ForceUpdateValueFromSourceToTarget();
_maxShotsBinding = this.SetBinding(() => Vm.MaxShots)
.WhenSourceChanges(() =>
{
MaxShotsEditText.Text = $"{Vm.MaxShots}";
});
_maxShotsBinding.ForceUpdateValueFromSourceToTarget();
_sliderStartPosBinding = this.SetBinding(() => Vm.SliderStartPosition)
.WhenSourceChanges(() =>
{
SliderStartPosEditText.Text = $"{Vm.SliderStartPosition}";
});
_sliderStartPosBinding.ForceUpdateValueFromSourceToTarget();
_sliderStopPosBinding = this.SetBinding(() => Vm.SliderStopPosition)
.WhenSourceChanges(() =>
{
SliderStopPosEditText.Text = $"{Vm.SliderStopPosition}";
});
_sliderStopPosBinding.ForceUpdateValueFromSourceToTarget();
_panStartPosBinding = this.SetBinding(() => Vm.PanStartPosition)
.WhenSourceChanges(() =>
//.........这里部分代码省略.........
示例3: SetupBindings
protected override void SetupBindings()
{
DetachBindings();
base.SetupBindings();
_hemisphereBinding = this.SetBinding(() => Vm.Direction)
.WhenSourceChanges(() =>
{
HemisphereValueLabel.Text = _hemispherePickerViewModel.Items[(int)Vm.Direction];
if ((AstroDirection)_hemispherePickerViewModel.SelectedIndex != Vm.Direction)
{
HemisphereValuePickerView.ReloadAllComponents();
HemisphereValuePickerView.Select((int)Vm.Direction, 0, !HemisphereValuePickerView.Hidden);
}
});
_hemisphereBinding.ForceUpdateValueFromSourceToTarget();
_speedBinding = this.SetBinding(() => Vm.Speed)
.WhenSourceChanges(() =>
{
SpeedValueLabel.Text = _speedPickerViewModel.Items[(int)Vm.Speed];
if ((AstroSpeed)_speedPickerViewModel.SelectedIndex != Vm.Speed)
{
SpeedValuePickerView.ReloadAllComponents();
SpeedValuePickerView.Select((int)Vm.Speed, 0, !SpeedValuePickerView.Hidden);
}
});
_speedBinding.ForceUpdateValueFromSourceToTarget();
_runStatusBinding = this.SetBinding(() => DeviceVm.RunStatus).WhenSourceChanges(() =>
{
var nav = ServiceLocator.Current.GetInstance<INavigationService>();
if (nav.CurrentPageKey != AppDelegate.ModeAstroViewKey) return;
if (DeviceVm.RunStatus != MoCoBusRunStatus.Stopped && nav.CurrentPageKey != AppDelegate.ModeAstroStatusViewKey && !_navigatedToStatusView && !DeviceVm.IsUpdateTaskRunning)
{
_navigatedToStatusView = true;
DeviceVm.StartUpdateTask();
nav.NavigateTo(AppDelegate.ModeAstroStatusViewKey, Vm);
}
});
_runStatusBinding.ForceUpdateValueFromSourceToTarget();
}
示例4: OnResume
public override void OnResume()
{
base.OnResume();
System.Diagnostics.Debug.WriteLine("ModeAstroViewFragment OnResume");
_prevRunStatus = MoCoBusRunStatus.Stopped;
_runStatusBinding = this.SetBinding(() => DeviceVm.RunStatus)
.WhenSourceChanges(() =>
{
lock (_runStatusLock)
{
if (DeviceVm.RunStatus != MoCoBusRunStatus.Stopped && DeviceVm.RunStatus != _prevRunStatus && !DeviceVm.IsUpdateTaskRunning)
{
var dlg = FragmentManager.FindFragmentByTag<DialogFragment>(Consts.DialogTag);
if (dlg == null)
{
var ft = FragmentManager.BeginTransaction();
ft.DisallowAddToBackStack();
var dlg2 = ModeAstroStatusViewFragment.NewInstance();
dlg2.Stoped += (oo, ee) => { };
dlg2.Paused += (oo, ee) => { };
dlg2.Resumed += (oo, ee) => { };
dlg2.SetCommand("Stoped", Vm.StopProgramCommand);
dlg2.SetCommand("Paused", Vm.PauseProgramCommand);
dlg2.SetCommand("Resumed", Vm.ResumeProgramCommand);
dlg2.Show(ft, Consts.DialogTag);
}
DeviceVm.StartUpdateTask();
}
}
_prevRunStatus = DeviceVm.RunStatus;
});
_runStatusBinding.ForceUpdateValueFromSourceToTarget();
_sliderAxisRadioBinding = this.SetBinding(() => SliderAxisRadioButton.Checked)
.WhenSourceChanges(() =>
{
if (SliderAxisRadioButton.Checked)
{
Vm.Motors |= Motors.MotorSlider;
}
else
{
Vm.Motors &= ~Motors.MotorSlider;
}
});
_panAxisRadioBinding = this.SetBinding(() => PanAxisRadioButton.Checked)
.WhenSourceChanges(() =>
{
if (PanAxisRadioButton.Checked)
{
Vm.Motors |= Motors.MotorPan;
}
else
{
Vm.Motors &= ~Motors.MotorPan;
}
});
_tiltAxisRadioBinding = this.SetBinding(() => TiltAxisRadioButton.Checked)
.WhenSourceChanges(() =>
{
if (TiltAxisRadioButton.Checked)
{
Vm.Motors |= Motors.MotorTilt;
}
else
{
Vm.Motors &= ~Motors.MotorTilt;
}
});
_mdkV5RadioBinding = this.SetBinding(() => MdkV5RadioButton.Checked)
.WhenSourceChanges(() =>
{
if (MdkV5RadioButton.Checked)
{
Vm.GearType = GearType.MdkV5;
}
});
_mdkV6RadioBinding = this.SetBinding(() => MdkV6RadioButton.Checked)
.WhenSourceChanges(() =>
{
if (MdkV6RadioButton.Checked)
{
Vm.GearType = GearType.MdkV6;
}
});
_nicOTiltRadioBinding = this.SetBinding(() => NicOTiltRadioButton.Checked)
.WhenSourceChanges(() =>
{
if (NicOTiltRadioButton.Checked)
{
Vm.GearType = GearType.NicOTilt;
}
//.........这里部分代码省略.........
示例5: SetupBindings
void SetupBindings()
{
_isConnectedBinding = this.SetBinding(() => Vm.IsConnected, () => ConnectButton.On, BindingMode.TwoWay).UpdateTargetTrigger("ValueChanged");
_isConnectedBinding.ValueChanged += (sender, e) =>
{
System.Diagnostics.Debug.WriteLine("DeviceViewModel PropertyChanged IsConnected");
OnConnectionOrProgramModeChanged();
};
_isConnectedBinding.ForceUpdateValueFromSourceToTarget();
_programModeBinding = this.SetBinding(() => Vm.ProgramMode).WhenSourceChanges(() =>
{
System.Diagnostics.Debug.WriteLine("DeviceViewModel PropertyChanged ProgramMode");
OnConnectionOrProgramModeChanged();
var navService = ServiceLocator.Current.GetInstance<INavigationService>();
switch (Vm.ProgramMode)
{
case MoCoBusProgramMode.ShootMoveShoot:
if (navService.CurrentPageKey != AppDelegate.ModeSmsViewKey && navService.CurrentPageKey != AppDelegate.ModeSmsStatusViewKey)
{
if (_modeChangeRequested || Vm.RunStatus != MoCoBusRunStatus.Stopped)
{
System.Diagnostics.Debug.WriteLine("Navigating to ModeSmsView since a mode change was requested");
_modeChangeRequested = false;
navService.NavigateTo(AppDelegate.ModeSmsViewKey, Vm.ModeSmsViewModel);
}
}
break;
case MoCoBusProgramMode.Panorama:
if (navService.CurrentPageKey != AppDelegate.ModePanoViewKey && navService.CurrentPageKey != AppDelegate.ModePanoStatusViewKey)
{
if (_modeChangeRequested || Vm.RunStatus != MoCoBusRunStatus.Stopped)
{
System.Diagnostics.Debug.WriteLine("Navigating to ModePanoView since a mode change was requested");
_modeChangeRequested = false;
navService.NavigateTo(AppDelegate.ModePanoViewKey, Vm.ModePanoViewModel);
}
}
break;
case MoCoBusProgramMode.Astro:
if (navService.CurrentPageKey != AppDelegate.ModeAstroViewKey && navService.CurrentPageKey != AppDelegate.ModeAstroStatusViewKey)
{
if (_modeChangeRequested || Vm.RunStatus != MoCoBusRunStatus.Stopped)
{
System.Diagnostics.Debug.WriteLine("Navigating to ModeAstroView since a mode change was requested");
_modeChangeRequested = false;
navService.NavigateTo(AppDelegate.ModeAstroViewKey, Vm.ModeAstroViewModel);
}
}
break;
}
});
_programModeBinding.ForceUpdateValueFromSourceToTarget();
}
示例6: SetupBindings
protected override void SetupBindings()
{
DetachBindings();
base.SetupBindings();
_exposureTimeBinding = this.SetBinding(() => Vm.ExposureTime).WhenSourceChanges(() =>
{
ExposureValueLabel.Text = $"{Vm.ExposureTime:F1}s";
if ((decimal)ExposureValuePickerTableViewCell.Model.SelectedTime.TotalSeconds != Vm.ExposureTime)
{
ExposureValuePickerTableViewCell.Model.SelectedTime = TimeSpan.FromSeconds((double)Vm.ExposureTime);
}
});
_exposureTimeBinding.ForceUpdateValueFromSourceToTarget();
_preDelayTimeBinding = this.SetBinding(() => Vm.PreDelayTime).WhenSourceChanges(() =>
{
PreDelayValueLabel.Text = $"{Vm.PreDelayTime:F1}s";
if ((decimal)PreDelayValuePickerTableViewCell.Model.SelectedTime.TotalSeconds != Vm.PreDelayTime)
{
PreDelayValuePickerTableViewCell.Model.SelectedTime = TimeSpan.FromSeconds((double)Vm.PreDelayTime);
}
});
_preDelayTimeBinding.ForceUpdateValueFromSourceToTarget();
_delayTimeBinding = this.SetBinding(() => Vm.DelayTime).WhenSourceChanges(() =>
{
PostDelayValueLabel.Text = $"{Vm.DelayTime:F1}s";
if ((decimal)PostDelayValuePickerTableViewCell.Model.SelectedTime.TotalSeconds != Vm.DelayTime)
{
PostDelayValuePickerTableViewCell.Model.SelectedTime = TimeSpan.FromSeconds((double)Vm.DelayTime);
}
});
_delayTimeBinding.ForceUpdateValueFromSourceToTarget();
_intervalTimeBinding = this.SetBinding(() => Vm.IntervalTime).WhenSourceChanges(() =>
{
IntervalValueLabel.Text = $"{Vm.IntervalTime:F1}s";
if ((decimal)IntervalValuePickerTableViewCell.Model.SelectedTime.TotalSeconds != Vm.IntervalTime)
{
IntervalValuePickerTableViewCell.Model.SelectedTime = TimeSpan.FromSeconds((double)Vm.IntervalTime);
}
});
_intervalTimeBinding.ForceUpdateValueFromSourceToTarget();
_durationTimeBinding = this.SetBinding(() => Vm.DurationTime).WhenSourceChanges(() =>
{
DurationValueLabel.Text = $"{(int) (Vm.DurationTime/60)}:{(int) Vm.DurationTime%60:00}m";
if ((decimal)DurationValuePickerTableViewCell.Model.SelectedTime.TotalSeconds != Vm.DurationTime)
{
DurationValuePickerTableViewCell.Model.SelectedTime = TimeSpan.FromSeconds((double)Vm.DurationTime);
}
});
_durationTimeBinding.ForceUpdateValueFromSourceToTarget();
_maxShotsBinding = this.SetBinding(() => Vm.MaxShots).WhenSourceChanges(() =>
{
ShotsValueLabel.Text = $"{Vm.MaxShots}";
if (ShotsValuePickerTableViewCell.Model.SelectedNumber != Vm.MaxShots)
{
ShotsValuePickerTableViewCell.Model.SelectedNumber = Vm.MaxShots;
}
});
_maxShotsBinding.ForceUpdateValueFromSourceToTarget();
_sliderStartPosBinding = this.SetBinding(() => Vm.SliderStartPosition).WhenSourceChanges(() =>
{
SliderStartPosValueLabel.Text = $"{Vm.SliderStartPosition}";
});
_sliderStartPosBinding.ForceUpdateValueFromSourceToTarget();
_sliderStopPosBinding = this.SetBinding(() => Vm.SliderStopPosition).WhenSourceChanges(() =>
{
SliderStopPosValueLabel.Text = $"{Vm.SliderStopPosition}";
});
_sliderStopPosBinding.ForceUpdateValueFromSourceToTarget();
_panStartPosBinding = this.SetBinding(() => Vm.PanStartPosition).WhenSourceChanges(() =>
{
PanStartPosValueLabel.Text = $"{(double) Vm.PanStartPosition/(190*200*16)*360:F1}°";
});
_panStartPosBinding.ForceUpdateValueFromSourceToTarget();
_panStopPosBinding = this.SetBinding(() => Vm.PanStopPosition).WhenSourceChanges(() =>
{
PanStopPosValueLabel.Text = $"{(double) Vm.PanStopPosition/(190*200*16)*360:F1}°";
});
_panStopPosBinding.ForceUpdateValueFromSourceToTarget();
_tiltStartPosBinding = this.SetBinding(() => Vm.TiltStartPosition).WhenSourceChanges(() =>
{
TiltStartPosValueLabel.Text = $"{(double) Vm.TiltStartPosition/(190*200*16)*360:F1}°";
});
_tiltStartPosBinding.ForceUpdateValueFromSourceToTarget();
_tiltStopPosBinding = this.SetBinding(() => Vm.TiltStopPosition).WhenSourceChanges(() =>
{
TiltStopPosValueLabel.Text = $"{(double) Vm.TiltStopPosition/(190*200*16)*360:F1}°";
});
//.........这里部分代码省略.........
示例7: OnResume
protected override void OnResume()
{
base.OnResume();
App.Initialize(this);
ServiceLocator.Current.GetInstance<DispatcherHelper>().SetOwner(this);
DisconnectedLayout.Visibility = ViewStates.Visible;
ConnectingLayout.Visibility = ViewStates.Gone;
ConnectedLayout.Visibility = ViewStates.Gone;
_isConnectedBinding = this.SetBinding(() => Vm.IsConnected, () => ConnectSwitch.Checked, BindingMode.TwoWay);
_showDisconnectedBinding = this.SetBinding(() => Vm.IsDisconnected, () => DisconnectedLayout.Visibility)
.ConvertSourceToTarget(b => b ? ViewStates.Visible : ViewStates.Gone);
_showConnectingBinding = this.SetBinding(() => Vm.IsConnecting, () => ConnectingLayout.Visibility)
.ConvertSourceToTarget(b => b ? ViewStates.Visible : ViewStates.Gone);
_showConnectedBinding = this.SetBinding(() => Vm.IsConnected)
.WhenSourceChanges(() =>
{
System.Diagnostics.Debug.WriteLine("DeviceViewActivity IsConnected Changed");
ConnectedLayout.Visibility = Vm.IsConnected ? ViewStates.Visible : ViewStates.Gone;
if (!Vm.IsConnected)
{
_programMode = MoCoBusProgramMode.Invalid;
System.Diagnostics.Debug.WriteLine("DeviceViewActivity IsConnected Changed: Search dialogs and close them");
var dlg = FragmentManager.FindFragmentByTag<DialogFragment>(Consts.DialogTag);
if (dlg != null)
{
System.Diagnostics.Debug.WriteLine("DeviceViewActivity IsConnected Changed: Found dialog, dismiss it");
dlg.DismissAllowingStateLoss();
}
System.Diagnostics.Debug.WriteLine("DeviceViewActivity IsConnected Changed: Search view fragment");
var f = FragmentManager.FindFragmentById<Fragment>(Resource.Id.ConnectedFragmentContainer);
if (f != null)
{
System.Diagnostics.Debug.WriteLine("DeviceViewActivity IsConnected Changed: Remove view fragment");
var ft = FragmentManager.BeginTransaction();
ft.Remove(f);
ft.SetTransition(FragmentTransit.FragmentFade);
ft.Commit();
}
System.Diagnostics.Debug.WriteLine("DeviceViewActivity IsConnected Changed: PopBackStackImmediate");
FragmentManager.PopBackStackImmediate(null, PopBackStackFlags.Inclusive);
System.Diagnostics.Debug.WriteLine("DeviceViewActivity IsConnected Changed: ExecutePendingTransactions");
FragmentManager.ExecutePendingTransactions();
}
});
_programMode = MoCoBusProgramMode.Invalid;
_programModeBinding = this.SetBinding(() => Vm.ProgramMode)
.WhenSourceChanges(OnProgramModeChanged);
_programModeBinding.ForceUpdateValueFromSourceToTarget();
}