private void DragSource_DragStart(object sender, Infragistics.DragDrop.DragDropStartEventArgs e)
        {
            dp           = Utilities.GetAncestorFromType(e.DragSource as DependencyObject, typeof(DataRecordPresenter), false) as DataRecordPresenter;
            currentIndex = dp.Record.Index;
            var          xdt        = e.DragSource as CardPanel;
            var          cpr        = xdt.TryFindParent <DataRecordPresenter>();
            var          ep         = cpr.DataRecord.DataItem as NeighborhoodWatch;
            var          dragSource = sender as DragSource;
            DataTemplate cardLayout = new DataTemplate();

            cardLayout.DataType = typeof(StackPanel);

            FrameworkElementFactory cardHolder = new FrameworkElementFactory(typeof(TextBlock));

            cardHolder.SetValue(TextBlock.TextProperty, string.IsNullOrWhiteSpace(ep.Computer) ? "New Computer" : ep.Computer);
            cardLayout.VisualTree   = cardHolder;
            dragSource.DragTemplate = cardLayout;
        }
Exemple #2
0
        private void DragSource_DragStart(object sender, Infragistics.DragDrop.DragDropStartEventArgs e)
        {
            var rightTreeVm = PageNavigatorHelper.GetRightElementViewModel();

            rightTreeVm.SetNodeDropable();
            var          xdt        = e.DragSource as Border;
            var          cpr        = xdt.TryFindParent <Expander>();
            var          ep         = cpr.DataContext as PolicyElementViewModel;
            var          dragSource = sender as DragSource;
            DataTemplate cardLayout = new DataTemplate();

            cardLayout.DataType = typeof(StackPanel);

            FrameworkElementFactory cardHolder = new FrameworkElementFactory(typeof(TextBlock));

            cardHolder.SetValue(TextBlock.TextProperty, ep.Name);
            cardHolder.SetValue(TextBlock.ForegroundProperty, (SolidColorBrush)(new BrushConverter().ConvertFrom(ep.ExpanderBackgroundColor)));
            cardLayout.VisualTree   = cardHolder;
            dragSource.DragTemplate = cardLayout;
        }