Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
2325
Drag drop Xam Data Grid
posted

Hi team,

Need help with the below scenario.

I have two Xam data grids  where i am using Drag drop manager to do drag & drop .

My Xam Data grid 1 & 2 are  bound to a class below.

public class Emp

{

     public int ID{get;set;}

     public  string Gender {get;set;}

}

The Dragsource & drop target  of a data record should be same either of male or female, if i am dragging  male onto a female record, then drop should not be allowed and  icon should change as in DropNotAllowedCursorTemplate .

XAML code for my XAM data grid ::

<Style TargetType="{x:Type igDP:CellValuePresenter}">
<Setter Property="Background" Value="Transparent"/>
<Setter Property="BorderBrush" Value="Transparent"/>
<Setter Property="BackgroundHover" Value="Transparent"/>
<Setter Property="BorderHoverBrush" Value="Transparent"/>
<Setter Property="BackgroundActive">
<Setter.Value>
<LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
<GradientStop Offset="0" Color="#FF85A2B2"/>
<GradientStop Offset="1.1" Color="#00FFFFFF"/>
</LinearGradientBrush>
</Setter.Value>
</Setter>
<Setter Property="BorderActiveBrush" Value="#00151C55"/>
<Setter Property="BackgroundSelected">
<Setter.Value>
<LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
<GradientStop Offset="0" Color="#FFCAEBFF"/>
<GradientStop Offset="1.1" Color="#00FFFFFF"/>
<GradientStop Color="#83CAEBFF" Offset="1"/>
</LinearGradientBrush>
</Setter.Value>
</Setter>
<Setter Property="BorderSelectedBrush" Value="#FF666666"/>
<Setter Property="BackgroundFieldSelected">
<Setter.Value>
<LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
<GradientStop Offset="0" Color="#FFDDDDDD"/>
<GradientStop Offset="1.1" Color="#00FFFFFF"/>
</LinearGradientBrush>
</Setter.Value>
</Setter>
<Setter Property="BorderFieldSelectedBrush" Value="#FF666666"/>
<Setter Property="BackgroundPrimary" Value="#7FE9E9E9"/>
<Setter Property="BorderPrimaryBrush" Value="#FFE9E9E9"/>
<Setter Property="ForegroundStyle">
<Setter.Value>
<Style/>
</Setter.Value>
</Setter>
<Setter Property="ForegroundActiveStyle" Value="{DynamicResource {ComponentResourceKey {x:Type igDP:XamDataGrid}, GrayForegroundStyle}}" />
<Setter Property="ForegroundAlternateStyle" Value="{DynamicResource {ComponentResourceKey {x:Type igDP:XamDataGrid}, GrayForegroundStyle}}" />
<Setter Property="ForegroundPrimaryStyle" Value="{DynamicResource {ComponentResourceKey {x:Type igDP:XamDataGrid}, GrayForegroundStyle}}" />
<Setter Property="ForegroundSelectedStyle" Value="{DynamicResource {ComponentResourceKey {x:Type igDP:XamDataGrid}, GrayForegroundStyle}}" />
<Setter Property="ForegroundFieldSelectedStyle" Value="{DynamicResource {ComponentResourceKey {x:Type igDP:XamDataGrid}, GrayForegroundStyle}}" />
<Setter Property="ForegroundHoverStyle" Value="{DynamicResource {ComponentResourceKey {x:Type igDP:XamDataGrid}, GrayForegroundStyle}}" />
<Setter Property="CornerRadius" Value="0"/>
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="Padding" Value="2,0,0,0"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type igDP:CellValuePresenter}">
<igWindows:CardPanel MouseDown="CardPanel_MouseDown" >

<ig:DragDropManager.DragSource>

<ig:DragSource IsDraggable="True" DragChannels="ChannelA"
Drop="DragSource_Drop" DragOver="DragSource_DragOver"
DragStart="DragSource_DragStart">

<ig:DragSource.DropNotAllowedCursorTemplate>
<DataTemplate>
<Ellipse Fill="Red" Width="25" Height="25" />
</DataTemplate>
</ig:DragSource.DropNotAllowedCursorTemplate>

</ig:DragSource>


</ig:DragDropManager.DragSource>


<Border
x:Name="MainBorder"
CornerRadius="{TemplateBinding CornerRadius}"
BorderThickness="{TemplateBinding BorderThickness}"
BorderBrush="{TemplateBinding BorderBrush}"
Background="{TemplateBinding Background}"/>
<Rectangle
x:Name="Active"
Fill="{TemplateBinding BackgroundActive}"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
Width="Auto"
Height="Auto"
SnapsToDevicePixels="True"
Opacity="1"
Visibility="Collapsed"
StrokeThickness="1"
Stroke="{TemplateBinding BorderActiveBrush}"/>
<ContentPresenter
x:Name="PART_EditorSite"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
Margin="{TemplateBinding Padding}"
Style="{TemplateBinding ForegroundStyle}"
>

</ContentPresenter>
</igWindows:CardPanel>
<ControlTemplate.Triggers>
<!-- HighlightAsPrimary -->
<Trigger Property="HighlightAsPrimary" Value="true">
<Setter Property="Background" Value="{Binding Path=BackgroundPrimary, RelativeSource={RelativeSource Self}}"/>
<Setter Property="BorderBrush" Value="{Binding Path=BorderPrimaryBrush, RelativeSource={RelativeSource Self}}"/>
<Setter TargetName="PART_EditorSite" Property="Style" Value="{Binding Path=ForegroundPrimaryStyle, RelativeSource={RelativeSource TemplatedParent}}"/>
</Trigger>
<!-- IsFieldSelected -->
<Trigger Property="IsFieldSelected" Value="true">
<Setter Property="Background" Value="{Binding Path=BackgroundFieldSelected, RelativeSource={RelativeSource Self}}"/>
<Setter Property="BorderBrush" Value="{Binding Path=BorderFieldSelectedBrush, RelativeSource={RelativeSource Self}}"/>
<Setter TargetName="PART_EditorSite" Property="Style" Value="{Binding Path=ForegroundFieldSelectedStyle, RelativeSource={RelativeSource TemplatedParent}}"/>
</Trigger>
<!-- IsSelected -->
<Trigger Property="IsSelected" Value="true">
<Setter Property="Background" Value="{Binding Path=BackgroundSelected, RelativeSource={RelativeSource Self}}"/>
<Setter Property="BorderBrush" Value="{Binding Path=BorderSelectedBrush, RelativeSource={RelativeSource Self}}"/>
<Setter TargetName="PART_EditorSite" Property="Style" Value="{Binding Path=ForegroundSelectedStyle, RelativeSource={RelativeSource TemplatedParent}}"/>
<!--<Setter Property="Visibility" Value="Visible" TargetName="LeftBorder" />-->
</Trigger>
<!-- IsActive -->
<Trigger Property="IsActive" Value="true">
<Setter TargetName="PART_EditorSite" Property="Style" Value="{Binding Path=ForegroundActiveStyle, RelativeSource={RelativeSource TemplatedParent}}"/>
<Setter Property="Visibility" TargetName="Active" Value="Visible"/>
</Trigger>
<!-- IsMouseOver -->
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsMouseOver" Value="True"/>
<Condition Property="IsSelected" Value="False"/>
<Condition Property="IsFieldSelected" Value="False"/>
</MultiTrigger.Conditions>
<Setter Property="Background" Value="{Binding Path=BackgroundHover, RelativeSource={RelativeSource Self}}"/>
<Setter Property="BorderBrush" Value="{Binding Path=BorderHoverBrush, RelativeSource={RelativeSource Self}}"/>
<Setter TargetName="PART_EditorSite" Property="Style" Value="{Binding Path=ForegroundHoverStyle, RelativeSource={RelativeSource TemplatedParent}}"/>
</MultiTrigger>
<!-- Field.IsFixedStateChanging JM 01-22-09 NA 9.1 FixedFields -->
<DataTrigger Binding="{Binding Path=Field.IsFixedStateChanging, RelativeSource={RelativeSource Self}}" Value="True">
<Setter Property="Background" Value="#AA8DBAEB"/>
<Setter Property="BorderBrush" Value="#AA8DBAEB"/>
</DataTrigger>
<!--SSP 5/27/09 NAS9.2 IDataErrorInfo Support-->
<Trigger Property="IsDataErrorTemplateActive" Value="true">
<Setter TargetName="PART_EditorSite" Property="ContentTemplate" Value="{DynamicResource {x:Static igDP:DataPresenterBase.DataErrorContentTemplateKey}}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<!-- DRCA Foreground Hover Trigger-->

<!-- JJD 4/30/09 - TFS17157 use new IsRecordSelected property -->
<Trigger Property="IsRecordSelected" Value="True">
<Setter Property="ForegroundStyle" Value="{DynamicResource {ComponentResourceKey {x:Type igDP:XamDataGrid}, GrayForegroundStyle}}" />
</Trigger>

<!-- DRCA Foreground Selected Trigger-->
<!-- JJD 4/30/09 - TFS17157 use new IsMouseOverRecord property -->
<Trigger Property="IsMouseOverRecord" Value="True">
<Setter Property="ForegroundStyle" Value="{DynamicResource {ComponentResourceKey {x:Type igDP:XamDataGrid}, GrayForegroundStyle}}" />
</Trigger>

</Style.Triggers>
</Style>

Parents
No Data
Reply
  • 30945
    Verified Answer
    Offline posted

    Hello,

     

    Thank you for your post. I have been looking into the functionality that you are trying to achieve and I have created  a sample application that demonstrates how you can restrict the Drag and Drop operation. I have used the DragEnter event of the DragSource and there, I am comparing the Gender property of the DragSrouce and DropTarget and if they are not equal, I am setting the e.OperationType to DragNotAllowed, in order to change the cursor. After doing so, in the Drop event I am checking the e.OperationType property and if it is DragNotAllowd, I am returning from the method.

     

    Please let me know if you need any further assistance on the matter.

     

    Sincerely,

    Krasimir

    Developer Support Engineer

    Infragistics

    www.infragistics.com/support

    DragDropRecordsBetweenGrids_1.zip
Children
No Data