Drag&Drop between RADgridview to itemcontrol

2 posts, 0 answers
  1. Senthil kumar
    Senthil kumar avatar
    21 posts
    Member since:
    Sep 2013

    Posted 04 Oct 2013 Link to this post

    currently, i am using on telerik RAD control version 2013.2.724.40. my assignment is to implement the dragdrop from RADGridview to itemcontrol. The itemscontrol contains a RADCartesianChart and when dropping a row from datagrid to itemcontrol to show the new chart for the related selected row.
    suppose, when dropping the selected row item in existing RADCartesianChart, then new lineseries and y-Axis (multiple Y-axis) to be created in same chart. (it will share same X-axis). if user drops the selected row out side the RADCartesianChart (but, within the itemscontrol), then created new chart with in the item control. 

    i have created ItemControlDragDropBehaviour as same as suggested in telerik's example. so, it works fine with itemscontrol. but, when i dropping the selected item with in existing chart in the itemscontros, it is not give the dropped chart control.

    how to find the chart control when dropping in exact chart control when dropping over the chart control in the itemscontrol.


    Code:

    <telerik:RadGridView Grid.RowSpan="2" Width="280" HorizontalContentAlignment="Stretch" VerticalAlignment="Stretch"
                                 Name="radGridView1" 
                                 ItemsSource="{Binding  Path=ChannelList, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, IsAsync=True}"
                                 AutoGenerateColumns="False" 
                                AllowDrop="True"
                                 demo:GridViewDragDropBehavior.IsEnabled="True"
                                 SelectionMode="Single"
                                 IsReadOnly="True"
                                 IsSynchronizedWithCurrentItem="True"
                                 SelectedItem="{Binding Path=SelectedChannel, IsAsync=True,UpdateSourceTrigger=PropertyChanged}"
                                     IsFilteringAllowed="True"
                                     ShowInsertRow="False"                                 
                                     CanUserDeleteRows="False"                                 
                                     CanUserInsertRows="False"
                                     CanUserReorderColumns="False"
                                     GridLinesVisibility="Horizontal"
                                     RowIndicatorVisibility="Collapsed" Margin="0,0,70,0">
                <telerik:RadGridView.Resources>
                    <DataTemplate x:Key="DraggedItemTemplate">
                        <StackPanel>
                            <StackPanel Orientation="Horizontal">
                                <TextBlock Text="Dragging:"/>
                                <TextBlock Text="{Binding CurrentDraggedItem.Name}" FontWeight="Bold"/>
                            </StackPanel>
                            <StackPanel Orientation="Horizontal">
                                <TextBlock Text="{Binding CurrentDropPosition}" FontWeight="Bold" MinWidth="45"/>
                                <TextBlock Text=", (" Foreground="Gray" />
                                <TextBlock Text="{Binding CurrentDraggedOverItem.Name}"/>
                                <TextBlock Text=")" Foreground="Gray" />
                            </StackPanel>
                        </StackPanel>
                    </DataTemplate>
                </telerik:RadGridView.Resources>
                <telerik:RadContextMenu.ContextMenu>
                    <telerik:RadContextMenu x:Name="radGridContextMenu" ItemsSource="{Binding SubMenus, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" >
                    </telerik:RadContextMenu>
                </telerik:RadContextMenu.ContextMenu>

                <telerik:RadGridView.RowStyle>
                    <Style TargetType="telerik:GridViewRow">
                        <Setter Property="telerik:DragDropManager.AllowDrag"
                               Value="True" />
                        <Setter Property="telerik:DragDropManager.TouchDragTrigger"
                               Value="TapAndHold"/>
                    </Style>
                </telerik:RadGridView.RowStyle>

                
                <telerik:RadGridView.Columns>
                    <telerik:GridViewDataColumn Header="Subsystem" IsSortable="True" IsFilterable="True" IsVisible="False" IsGroupable="True" Width="*" DataMemberBinding="{Binding SubsystemText}"/>
                    <telerik:GridViewDataColumn Header="Show" Width="30">
                        <telerik:GridViewDataColumn.CellTemplate>
                            <DataTemplate>
                                <CheckBox IsThreeState="False" IsChecked="{Binding Selected, Mode=TwoWay}" FlowDirection="RightToLeft" />
                            </DataTemplate>
                        </telerik:GridViewDataColumn.CellTemplate>
                    </telerik:GridViewDataColumn>
                    <telerik:GridViewDataColumn Header="ID" IsSortable="True" IsFilterable="True" IsGroupable="True" Width="50" DataMemberBinding="{Binding SubsystemId}"/>
                    <telerik:GridViewDataColumn Header="Signal" IsSortable="True" IsFilterable="True" IsGroupable="True" Width="*" DataMemberBinding="{Binding Name}">
                        <telerik:GridViewDataColumn.ToolTipTemplate>
                            <DataTemplate>
                                <TextBlock Text="{Binding Name}"/>
                            </DataTemplate>
                        </telerik:GridViewDataColumn.ToolTipTemplate>
                    </telerik:GridViewDataColumn>
                </telerik:RadGridView.Columns>
            </telerik:RadGridView>
          
            <ScrollViewer  Margin="2" VerticalAlignment="Stretch"  CanContentScroll="True" Grid.Column="1" Grid.Row="1">
                <ItemsControl x:Name="chartHost"  BorderThickness="2"  BorderBrush="Black"   VerticalAlignment="Stretch"  demo:ItemControlDragDropBehaviour.IsEnabled="True" AllowDrop="True"  ItemsSource="{Binding SelectedSignals, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" HorizontalAlignment="Stretch" HorizontalContentAlignment="Stretch">

                <ItemsControl.ItemsPanel>
                    <ItemsPanelTemplate>
                        <StackPanel Orientation="Vertical" Margin="2" Background="Chocolate" />
                    </ItemsPanelTemplate>
                </ItemsControl.ItemsPanel>

                <ItemsControl.ItemTemplate>
                    <DataTemplate>
      <Border BorderThickness="1" BorderBrush="Black" Grid.Row="0">
                <StackPanel Orientation="Vertical">
             <chart:RadCartesianChart x:Name="Chart1"   Height="400" Grid.Row="0" Palette="Windows8" Margin="6,0,20,0" >
                <chart:RadCartesianChart.Resources>
                    <DataTemplate x:Key="PointTemplate1">
                        <Ellipse Height="6" Width="6" Fill="#FF8EC441" />
                    </DataTemplate>
                    <DataTemplate x:Key="PointTemplate2">
                        <Ellipse Height="6" Width="6" Fill="#FF1B9DDE" />
                    </DataTemplate>
                </chart:RadCartesianChart.Resources>
                <chart:RadCartesianChart.HorizontalAxis>
                    <chartView:DateTimeContinuousAxis PlotMode="OnTicks" LabelFitMode="Rotate" LabelRotationAngle="45"  MajorStepUnit="Second" Minimum="{Binding AxisXMinValue}"
                                                    LabelInterval="5"
                                                    LabelFormat="hh:mm:ss" />
                </chart:RadCartesianChart.HorizontalAxis>
                <telerik:RadCartesianChart.Grid>
                    <telerik:CartesianChartGrid MajorLinesVisibility="Y" StripLinesVisibility="Y" MajorXLineStyle="{StaticResource StripLinesStyle}" MajorYLineStyle="{StaticResource StripLinesStyle}"/>
                </telerik:RadCartesianChart.Grid>
                <chart:RadCartesianChart.VerticalAxis>
                    <chartView:LinearAxis />
                </chart:RadCartesianChart.VerticalAxis>
                 <demo:LinearSeriesSourceChange.LinearSeriesSource>
                            <Binding Path="ChartList" Mode="TwoWay" UpdateSourceTrigger="PropertyChanged"  />
                 </demo:LinearSeriesSourceChange.LinearSeriesSource>
                <telerik:RadCartesianChart.Behaviors>
                    <telerik:ChartPanAndZoomBehavior ZoomMode="Both" PanMode="Both" >
                    </telerik:ChartPanAndZoomBehavior>
                </telerik:RadCartesianChart.Behaviors>
             
            </chart:RadCartesianChart>





     public static class LinearSeriesSourceChange
        {

            public static readonly DependencyProperty LinearSeriesSourceProperty = DependencyProperty.RegisterAttached("LinearSeriesSource",
                typeof(ObservableCollection<HistoricalChannel>), typeof(LinearSeriesSourceChange), new PropertyMetadata(OnLinearSeriesSourceChanged));

            public static ObservableCollection<HistoricalChannel> GetLinearSeriesSource(DependencyObject obj)
            {
                return (ObservableCollection<HistoricalChannel>)obj.GetValue(LinearSeriesSourceProperty);
            }

            public static void SetLinearSeriesSource(DependencyObject obj, ObservableCollection<HistoricalChannel> value)
            {
                obj.SetValue(LinearSeriesSourceProperty, value);
            }

            private static void OnLinearSeriesSourceChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
            {
                ObservableCollection<string> s = new ObservableCollection<string>();
                s.Add("#8ec441");
                s.Add("#1b9dde");
                s.Add("#f59700");
                s.Add("#d4df32");
            

                RadCartesianChart chart = sender as RadCartesianChart;
                if (chart == null)
                    return;
                ObservableCollection<HistoricalChannel> seriesModel = e.NewValue as ObservableCollection<HistoricalChannel>;

                int iCount = 0;
                LinearAxis linearAxis = chart.VerticalAxis as LinearAxis;
                List<CartesianSeries> generatedSeries = new List<CartesianSeries>();
                chart.Series.Clear();
                foreach (HistoricalChannel histriocallist in seriesModel)
                {


                    //        CategoricalSeriesDescriptor a = new CategoricalSeriesDescriptor();
                    RadObservableCollection<SalesRevenue> list = histriocallist.Data;
                    // chart.Series.Clear();

                    LineSeries a = new LineSeries();
                    a.ItemsSource = list;
                   
                    LineSeries lineSeries = new LineSeries();
                    string pointTemplatePath = string.Format("PointTemplate{0}", iCount + 1);
                    lineSeries.PointTemplate = chart.Resources[pointTemplatePath] as DataTemplate;
                    
                    SeriesLegendSettings legend1 = new SeriesLegendSettings() { Title = "My Title" + iCount.ToString() };
                    lineSeries.LegendSettings = legend1;
                    lineSeries.CategoryBinding = new PropertyNameDataPointBinding("Timestamp");
                    lineSeries.ValueBinding = new PropertyNameDataPointBinding("Revenue");
                    lineSeries.ItemsSource = list;

                    if (iCount != 0)
                     {
                         linearAxis = new LinearAxis();
                     }
                     if (iCount % 2 == 1)
                     {
                         if (linearAxis != null)
                         {
                             linearAxis.HorizontalLocation = AxisHorizontalLocation.Right;
                             linearAxis.Title = "Tile" + (iCount + 1).ToString();
                             linearAxis.ElementBrush = new SolidColorBrush((Color)ColorConverter.ConvertFromString(s[iCount]));
                             if (iCount != 0)
                             {
                                 lineSeries.VerticalAxis = linearAxis;
                             }
                           
                         }

                     }
                     else
                     {
                         linearAxis = new LinearAxis();
                         linearAxis.HorizontalLocation = AxisHorizontalLocation.Left;
                         
                         linearAxis.Title = "Tile" + (iCount + 1).ToString();
                         linearAxis.ElementBrush = new SolidColorBrush((Color)ColorConverter.ConvertFromString(s[iCount]));
                         lineSeries.VerticalAxis = linearAxis;
                     }
              
                    chart.Series.Add(lineSeries);
                    iCount++;
                }
             }
           }
        }
     
  2. Senthil kumar
    Senthil kumar avatar
    21 posts
    Member since:
    Sep 2013

    Posted 14 Oct 2013 Link to this post

    Hi Team,

    do you have any solution for this problem which posted in above?. i am waiting for your answer..
  3. UI for WPF is Visual Studio 2017 Ready
Back to Top