We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add "Command" property for ToggleSwitch control
The text was updated successfully, but these errors were encountered:
AttachedProperty:
using System; using System.Windows; using System.Windows.Input; using MahApps.Metro.Controls; namespace e3Shell.StandMaterialsSpecification.Behaviors { public class ToggleSwitchBehavior { public static readonly DependencyProperty CommandProperty = DependencyProperty.RegisterAttached("Command", typeof(ICommand), typeof(ToggleSwitchBehavior), new UIPropertyMetadata(null, OnIsExternalChanged)); public static ICommand GetCommand(DependencyObject obj) { return (ICommand)obj.GetValue(CommandProperty); } public static void SetCommand(DependencyObject obj, ICommand value) { obj.SetValue(CommandProperty, value); } private static void OnIsExternalChanged(object sender, DependencyPropertyChangedEventArgs args) { var toggleSwitch = sender as ToggleSwitch; if (toggleSwitch == null) return; if (args.NewValue != null) toggleSwitch.IsCheckedChanged += IsCheckedChangedHandler; else toggleSwitch.IsCheckedChanged -= IsCheckedChangedHandler; } private static void IsCheckedChangedHandler(object sender, EventArgs e) { var command = GetCommand((ToggleSwitch)sender); if (command.CanExecute(null)) command.Execute(null); } } }
In your XAML:
xmlns:behaviors="clr-namespace:e3Shell.StandMaterialsSpecification.Behaviors"
<controls:ToggleSwitch behaviors:ToggleSwitchBehavior.Command="{Binding Path=OpenAboutFlyoutCommand}"/>
Sorry, something went wrong.
introduce CheckedCommand #1464
eaaa911
punker76
No branches or pull requests
Add "Command" property for ToggleSwitch control
The text was updated successfully, but these errors were encountered: