Exemplo n.º 1
0
        private static void ToggleBlade(object sender, TappedRoutedEventArgs tappedRoutedEventArgs)
        {
            Button       pressedButton = sender as Button;
            string       bladeName     = GetToggleBlade(pressedButton);
            BladeControl container     = pressedButton.FindVisualAscendant <BladeControl>();
            var          blade         = container.Items.OfType <Blade>().FirstOrDefault(_ => _.BladeId == bladeName);

            if (blade == null)
            {
                throw new KeyNotFoundException($"Could not find a blade with ID {bladeName}");
            }

            blade.IsOpen = !blade.IsOpen;
        }
Exemplo n.º 2
0
        private static void ToggleBlade(object sender, TappedRoutedEventArgs tappedRoutedEventArgs)
        {
            Button       pressedButton = sender as Button;
            string       bladeName     = GetToggleBlade(pressedButton);
            BladeControl container     = pressedButton.FindVisualAscendant <BladeControl>();
            var          blade         = container.Blades.FirstOrDefault(_ => _.BladeId == bladeName);

            if (blade == null)
            {
                throw new KeyNotFoundException($"Could not find a blade with ID {bladeName}");
            }

            if (blade.IsOpen)
            {
                blade.IsOpen = false;
                BladeClosed?.Invoke(container, blade);
            }
            else
            {
                blade.IsOpen = true;
                BladeOpened?.Invoke(container, blade);
            }
        }