コード例 #1
0
ファイル: MainWindow.xaml.cs プロジェクト: kcjerrell/MyLights
        private void LightPanel_FlyoutRequest(object sender, Views.FlyoutRequestEventArgs e)
        {
            //MessageBoxResult result = System.Windows.MessageBox.Show(((LightViewModel)e.Source.DataContext).Name);

            if (sender is FrameworkElement element)
            {
                Canvas.SetLeft(flyoutFrame, e.FlyoutPosition.X);
                Canvas.SetTop(flyoutFrame, e.FlyoutPosition.Y);
                flyoutFrame.DataContext = e.Source;
                flyoutShade.Visibility  = Visibility.Visible;
                flyoutFrame.Visibility  = Visibility.Visible;
                flyoutCallback          = e.FlyoutClosedCallBack;
            }
        }
コード例 #2
0
        private void SomeMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            if (mouseDragging)
            {
                mouseDragging = false;

                var args = new FlyoutRequestEventArgs();

                var selected = (from LightViewModel lvm in itemsControl.Items
                                where lvm.IsSelected
                                select lvm).ToList();

                if (selected.Count == 0)
                {
                    return;
                }

                else if (selected.Count == 1)
                {
                    args.Source = selected[0];
                }

                else if (selected.Count > 1)
                {
                    foreach (var s in selected)
                    {
                        //lightGroup.LightGroup.Add(s.Light);
                    }
                    //args.Source = lightGroup;
                }

                args.FlyoutClosedCallBack = FlyoutClosedCallBack;

                var container = (FrameworkElement)itemsControl.ItemContainerGenerator.ContainerFromItem(selected.First());
                args.FlyoutPosition = container.TranslatePoint(new Point(container.ActualWidth, 0.0), null);

                var handler = FlyoutRequest;
                handler?.Invoke(this, args);
            }
        }