Telerik Forums
UI for WPF Forum
12 answers
200 views
Hello Telerik Team,

For understanding my problem first please see attached file.

When am dragging Order (Order-09 in orderdetail tab of Tour 2) & dropping to Tour 3, am getting reference of Tour 1 instead of Tour 3. Am using Drag & Drop control of Telerik only. DropInfo am handling like below:

If

 

 

e.Options.Status = DragStatus.DropComplete Then   

 

    Dim row As RadTileViewItem = TryCast(e.Source, RadTileViewItem)
End IF

row am aspacting tour 3 content not Tour 1. This thing happens randomly and am not able to track when it gives me wrong reference.

Solution: if am maximized Tour 3 and again maximized tour 2. if now am dropping same then i am getting tour 3 row which i want.

One thing am doing is While TileStateChanged am checking if it is maximized item then Item Max Height/Width equals to Windows Max Height/Width other wise it restricted to 200 as am want some specific size of box.

Is that the reason or something else? 

Thanks...!!!

 

 

Tina Stancheva
Telerik team
 answered on 29 Jul 2010
1 answer
86 views
When sorting in RadGridView, where are the data values that are used to sort sourced from?  It appears, that when defining a custom data type, using type descriptors, the data values are obtained from the data set for which the grid displays.  If the data set is not defining custom data types, then it appears to use values in the internal visual elements?
Vlad
Telerik team
 answered on 29 Jul 2010
1 answer
101 views
We've got a WPF window based on the carousel control, but when we put buttons on this user control and assign a mouseleftbuttondown (or any mouse button) event to the button, it doesn't fire.

I have found out though that when we use PreviewMouseLeftButtonDown the event fires fine, which suggests there is a problem with the bubbling of events through Telerik controls.

Is this a bug?
Miroslav
Telerik team
 answered on 29 Jul 2010
1 answer
275 views
Hello Sir/Madam
i m working on wpf application and i am using web Browser in my application .
i want to customize the scrollabar in webBrowser.
it means that i just disable the existing scrollabar and apply my scrollBar style in webBrowser.
please help me as early as possible.

Thanks in advance.
Vinod Nagda
Miroslav
Telerik team
 answered on 29 Jul 2010
5 answers
306 views
I typically avoid binding.  I'm a bit old school and I've been burned many times by binding but I know I'd benefit from having another tool in my collection.  So, I thought I'd try again.  Thanks in advance for your help.

I'm comfortable with basic binding.  If I have a TextBox and I set the TextBox.Text value like this it seems to work fine:
<TextBox x:Name="txtFirstName"   
 Text="{Binding Path=FirstName}" /> 

However, I created a UserControl in a WindowsHelper class called a LabelTextBox.  Pretty much any time you show a combobox or textbox (etc) on a form you place a Label to the left of it to explain what it is.  So, why not just have one control to define on a form instead of 2?

Now, I want to use DataBinding to show data in the TextBox from my DataContext.  This is where it gets a little complicated.  I expose a public DependencyProperty named Text from my LabelTextBox.  I did this so the programmer can define the UserControl by typing txtName.Text = "Joel".  This Text property then needs to bind to the TextBox.Text property inside the LabelTextBox.  So, any time a value changes on the ModelView (MV), it needs to propigate from MV --> LabelTextBox.Text --> TextBox.Text and back again.

        public string Text  
        {  
            get { return (string)GetValue(TextProperty); }  
            set { SetValue(TextProperty, value); }  
        }  
 
        // Using a DependencyProperty as the backing store for Text.  This enables animation, styling, binding, etc...  
        public static readonly DependencyProperty TextProperty =  
            DependencyProperty.Register("Text", typeof(string), typeof(LabelTextBox)); 

Anyone have a quick example of how I accomplish this?
Joel Palmer
Top achievements
Rank 2
 answered on 28 Jul 2010
1 answer
163 views
I have a RadGrid that is being used to display settings for a user control. One of the settings is a font listing for each label on the control. I need this column to be a combobox-column. The problem I am having is that when I use the recommended approach to populating the data for this column I get a choice of only those fonts that have be set and listed in the database. What I need is a combobox in the datagrid with a listing of the system fonts as the ItemSource and the DisplayMemberPath, and SelectedValueMemberPath pointing to the data source. However, this does not seems to work. I think that the only way to do this is to provide some sort of datatable with a column having the same name as the targeted "Font Column" in the data source. Any ideas?
OverCoded
Top achievements
Rank 2
 answered on 28 Jul 2010
1 answer
74 views
How can I sign up for email notification of external releases of the WPF controls?

-eric
Hristo
Telerik team
 answered on 28 Jul 2010
1 answer
264 views
Hi,

I want to do something on GridViewRow if the CheckBox of that Row is Checked. How to trigger the event when CheckBox in GridViewSelectColumn is checked?  I have to use GridViewSelectColumn cause my app need to support multiple Checked.
Could you give me some suggestion? Thanks!
 
Maya
Telerik team
 answered on 28 Jul 2010
3 answers
77 views
The main product pages still mention .Net 3.5, and the download file is titled "RadControls_for_WPF_35_2010_2_0714_DEV.msi", which seems to indicate that it's for .Net 3.5.
Hristo
Telerik team
 answered on 28 Jul 2010
1 answer
168 views
Hello,

I have 3 RadGridViews out of which one is the source and two are destinations. The two destination radgridviews are on the RadTab Control. Drag and Drop functionality works fine between Source and one of the destination except that the events are not hit for the dropping position of the Row (Insert after/before row not seen).

When I try to drag the source onto the second radgridview destination, the drop functionality doesnt seem to work (Drag is showing me the object dragged, but drop isnt showing any text of adding.... I have noticed the e.Option.Status is always DragCancel when i try to drop the row in the 2 grid).

I did make a copy of the 1st destination (working) and tried to include it as the 2nd destination, but still no luck in getting it to work. Also I did make copy of the events which I could consume conditionally thinking that it is unable to register those events.

Source Code is as follows:-
XAML

<

 

Page.Resources>
.
.

 

 

 

..    <Style TargetType="telerikGrid:GridViewRow" x:Key="Grid1ItemStyle">

 

 

 

        <Setter Property="dragDrop:RadDragAndDropManager.AllowDrop" Value="True" />

 

 

 

        <Setter Property="dragDrop:RadDragAndDropManager.AllowDrag" Value="True" />

 

 

 

    </Style>
    <Style TargetType="telerikGrid:GridViewRow" x:Key="Grid2ItemStyle">

 

 

 

        <Setter Property="dragDrop:RadDragAndDropManager.AllowDrop" Value="True" />

 

 

 

 

 

 

        <Setter Property="dragDrop:RadDragAndDropManager.AllowDrag" Value="True" />

 

 

 

 

 

 

    </Style>

    <

 

DataTemplate x:Key="ProductTemplate">

 

 

 

 

 

 

        <DockPanel Margin="2" MaxWidth="200">

 

 

 

 

 

 

            <TextBlock Text="{Binding TableName}" FontWeight="Bold" DockPanel.Dock="Top" />

 

 

 

 

 

 

            <TextBlock Text="{Binding ColumnName}" Foreground="Green" DockPanel.Dock="Left" />

 

 

 

 

 

 

            <TextBlock Text="{Binding ColumnFriendlyName}" DockPanel.Dock="Left" Margin="2 0 0 0" Foreground="Gray" TextWrapping="Wrap" />

 

 

 

 

 

 

        </DockPanel>

 

 

 

 

 

 

    </DataTemplate>

 

 

 

 

 

 

    <DataTemplate x:Key="Product1Template">

 

 

 

 

 

 

        <DockPanel Margin="2" MaxWidth="200">

 

 

 

 

 

 

            <TextBlock Text="{Binding Table1Name}" FontWeight="Bold" DockPanel.Dock="Top" />

 

 

 

 

 

 

            <TextBlock Text="{Binding Column1Name}" Foreground="Green" DockPanel.Dock="Left" />

 

 

 

 

 

 

        </DockPanel>

 

 

 

 

 

 

    </DataTemplate>

 

 

 

 

 

.
.
</
Page.Resources>

 

 

 

<Grid>

 

.
.
.

 

<

 

telerik:RadGridView x:Name="gridSourceTableColumns" Margin="10,0,8,0" AutoGenerateColumns="False" ShowGroupPanel="False"

 

 

 

HorizontalAlignment="Stretch" CanUserFreezeColumns="False" telerik:StyleManager.Theme="Windows7" CanUserReorderColumns="False" ScrollMode="RealTime" Height="300" CanUserSortColumns="False" Width="Auto" IsReadOnly="False" RowIndicatorVisibility="Collapsed" Grid.ColumnSpan="2" SelectionMode="Multiple" Grid.Row="0" Grid.Column="0"  Loaded="gridSourceTableColumns_Loaded" CanUserInsertRows="True" dragDrop:RadDragAndDropManager.AllowDrag="True" RowStyle="{StaticResource Grid1ItemStyle}" >

 

 

 

.
.
.

 

</

 

telerik:RadGridView>

 

 

 

.
.
.

 

<

 

telerikNavigation:RadTabControl x:Name="tabDEEParameters" Grid.Row="2" Grid.Column="0" Height="250">

 

 

 

 

 

 

    <telerikNavigation:RadTabItem Header="Where Clause" x:Name="tabItemWhereClause">

 

 

 

 

 

 

        <telerik:RadGridView x:Name="grdSrcWhereClause" Margin="10,0,8,0" AutoGenerateColumns="False" ShowGroupPanel="False"

 

 

            HorizontalAlignment="Stretch" CanUserFreezeColumns="False"  CanUserSortColumns="False" ItemsSource="{Binding}"

 

 

            IsReadOnly="False" RowIndicatorVisibility="Collapsed" ScrollMode="RealTime" Width="Auto" IsFilteringAllowed="False"

 

 

            Grid.Row="1" Grid.ColumnSpan="2" Height="200" RowEditEnded="OnRowEditEnded" CanUserDeleteRows="True"

 

 

 

 

 

            CanUserInsertRows="True" RowStyle="{StaticResource Grid2ItemStyle}"

 

 

 

            dragDrop:RadDragAndDropManager.AllowDrop="True" CanUserReorderColumns="False"  >

 

 

 

 

 

 

.
.
.

 

    </

 

telerik:RadGridView>

 

 

 

 

</

 

telerikNavigation:RadTabItem>

 

 

 

 

<

 

telerikNavigation:RadTabItem Header="Join Parameters" x:Name="tabItemJoinParameters">

 

 

 

 

 

 

    <telerik:RadGridView x:Name="grdSrcJoinParameter" Margin="10,0,8,0" AutoGenerateColumns="False" ShowGroupPanel="False"

 

 

        HorizontalAlignment="Stretch" CanUserFreezeColumns="False" CanUserReorderColumns="False"

 

 

        CanUserSortColumns="False" Width="Auto" ItemsSource="{Binding}"

 

 

        IsReadOnly="False" RowIndicatorVisibility="Collapsed" ScrollMode="RealTime"

 

 

        Grid.Row="1" Grid.ColumnSpan="2" Height="200" RowEditEnded="OnRowEditEnded"

 

 

 

 

 

        CanUserInsertRows="True" CanUserDeleteRows="True" IsFilteringAllowed="False"

 

 

 

 

 

        dragDrop:RadDragAndDropManager.AllowDrop="True" AllowDrop="True"

 

 

 

 

 

        RowStyle="{StaticResource Grid2ItemStyle}">

 

 

 

 

 

 

.
.
.
.
.
        
</telerik:RadGridView>

 

 

 

 

 

 

</telerikNavigation:RadTabItem>

 

 

 

</telerikNavigation:RadTabControl>

 

 

 

.
.
.
.
.
</

 

Grid>

 



C# Code is as follows:-

Constructor:-..... Initialise...

public

 

SAPSourceTableDetails()

 

{

 

   // Allow dropping into the GridView only if the drop items:

 

 

    RadDragAndDropManager.AddDragQueryHandler(gridSourceTableColumns, OnDragQuery);

 

 

    // Change the dropping cue and choose an action for the sucessful drop in the GridView:

 

 

    RadDragAndDropManager.AddDragInfoHandler(gridSourceTableColumns, OnGridViewDragInfo);

 

 

 

    // Allow dropping into the GridView only if the dragged items:

 

 

    RadDragAndDropManager.AddDropQueryHandler(grdSrcWhereClause, OnDropQuery);

 

 

    // Change the dropping cue and choose an action for the sucessful drag in the GridView:

 

 

    RadDragAndDropManager.AddDropInfoHandler(grdSrcWhereClause, OnGridViewDropInfo);

 

 

 

     

// Allow dropping into the GridView only if the drop items:

 

 

    RadDragAndDropManager.AddDragQueryHandler(grdSrcJoinParameter, OnDropJoinQuery);

 

 

    // Change the dropping cue and choose an action for the sucessful drop in the GridView:

 

 

    RadDragAndDropManager.AddDragInfoHandler(grdSrcJoinParameter, OnGridViewDropJoinInfo);

 

 

 

 

    //Add class handler to handle dropping before / after items:

 

 

    EventManager.RegisterClassHandler(typeof(GridViewRow), RadDragAndDropManager.DropQueryEvent, new     
    EventHandler
<DragDropQueryEventArgs>(OnRowDropQuery));

 

 

    EventManager.RegisterClassHandler(typeof(GridViewRow), RadDragAndDropManager.DropInfoEvent, new     
    EventHandler
<DragDropEventArgs>(OnRowDropInfo));

 



 

    // Make the GridView a drag Source:

 

 

    RadDragAndDropManager.SetAllowDrag(gridSourceTableColumns, true);

 

 

 

    // Make the GridView a drop target:

 

 

 

    RadDragAndDropManager.SetAllowDrop(grdSrcWhereClause, true);

 

 

    // Make the GridView a drag Source:

 

 

 

    RadDragAndDropManager.SetAllowDrop(grdSrcJoinParameter, true);

 

    tabDEEParameters.SelectedIndex = 2;


}
...

private

 

DropPosition lastRowDropPosition;

 

 


 

// Get the drag cue that we have created

 

 

 

private

 

void OnRowDropInfo(object sender, DragDropEventArgs e)

 

{

 

var row = sender as GridViewRow;

 

 

var gridView = row.GridViewDataControl as RadGridView;

 

 

var draggedItems = e.Options.Payload as ICollection;

 

 

// Get the drag cue that we have created

 

 

var cue = e.Options.DragCue as TreeViewDragCue;

 

 

 

if (e.Options.Status == DragStatus.DropPossible)

 

{

 

// Set a suitable text:

 

cue.DragActionContent =

String.Format("Insert {0} item{1} {2} ", draggedItems.Count, draggedItems.Count > 1 ? "s" : String.Empty, lastRowDropPosition.ToString().ToLower());

 

cue.DragTooltipContent = row.Item;

cue.DragTooltipContentTemplate =

this.Resources["ProductTemplate"] as DataTemplate;

 

grdSrcWhereClause.SetIsSelected(grdSrcWhereClause.SelectedItem,

true);

 

ShowBetweenItemsCue(gridView, row, lastRowDropPosition);

 

//We need to think of some kind of template here, we will use one we have.

 

cue.IsDropPossible =

true;

 

}

 

else if (e.Options.Status == DragStatus.DropImpossible)

 

{

HideBetweenItemsCue(gridView);

cue.DragActionContent =

null;

 

cue.IsDropPossible =

false;

 

}

 

else if (e.Options.Status == DragStatus.DropComplete)

 

{

HideBetweenItemsCue(gridView);

 

var items = gridView.ItemsSource as IList;

 

 

var insertIndex = items.IndexOf(row.Item);

 

 

if (lastRowDropPosition == DropPosition.After)

 

{

insertIndex++;

}

 

foreach (var draggedItem in draggedItems)

 

{

items.Insert(insertIndex, draggedItem);

insertIndex++;

}

}

e.Handled =

true;

 

}

 

private void OnRowDropJoinInfo(object sender, DragDropEventArgs e)

 

{

 

var row = sender as GridViewRow;

 

 

var gridView = row.GridViewDataControl as RadGridView;

 

 

var draggedItems = e.Options.Payload as ICollection;

 

 

// Get the drag cu that the TreeView or we have created

 

 

var cue = e.Options.DragCue as TreeViewDragCue;

 

 

 

if (e.Options.Status == DragStatus.DropPossible)

 

{

 

// Set a suitable text:

 

cue.DragActionContent =

String.Format("Insert {0} item{1} {2} ", draggedItems.Count, draggedItems.Count > 1 ? "s" : String.Empty, lastRowDropPosition.ToString().ToLower());

 

cue.DragTooltipContent = row.Item;

cue.DragTooltipContentTemplate =

this.Resources["Product1Template"] as DataTemplate;

 

grdSrcJoinParameter.SetIsSelected(grdSrcWhereClause.SelectedItem,

true);

 

ShowBetweenItemsCue(gridView, row, lastRowDropPosition);

 

//We need to think of some kind of template here, we will use one we have.

 

cue.IsDropPossible =

true;

 

}

 

else if (e.Options.Status == DragStatus.DropImpossible)

 

{

HideBetweenItemsCue(gridView);

cue.DragActionContent =

null;

 

cue.IsDropPossible =

false;

 

}

 

else if (e.Options.Status == DragStatus.DropComplete)

 

{

HideBetweenItemsCue(gridView);

 

var items = gridView.ItemsSource as IList;

 

 

var insertIndex = items.IndexOf(row.Item);

 

 

if (lastRowDropPosition == DropPosition.After)

 

{

insertIndex++;

}

 

foreach (var draggedItem in draggedItems)

 

{

items.Insert(insertIndex, draggedItem);

insertIndex++;

}

}

e.Handled =

true;

 

}

 

 

private void ShowBetweenItemsCue(RadGridView gridView, GridViewRow row, DropPosition lastRowDropPosition)

 

{

 

if (gridView != null)

 

{

 

//We need to get the first visual child so that we can search in the template:

 

 

var firstChild = VisualTreeHelper.GetChild(gridView, 0) as FrameworkElement;

 

 

var cue = firstChild.FindName("BetweenItemsCue") as FrameworkElement;

 

cue.Visibility =

Visibility.Visible;

 

 

//How much should the cue be offset?

 

 

var yOffset = row.TransformToVisual(gridView).Transform(new Point()).Y;

 

 

if (lastRowDropPosition == DropPosition.After)

 

{

yOffset += row.ActualHeight;

}

cue.RenderTransform =

new TranslateTransform() { Y = yOffset };

 

}

}

 

private void HideBetweenItemsCue(RadGridView gridView)

 

{

 

if (gridView != null)

 

{

 

//We need to get the first visual child so that we can search in the template:

 

 

var firstChild = VisualTreeHelper.GetChild(gridView, 0) as FrameworkElement;

 

 

var cue = firstChild.FindName("BetweenItemsCue") as FrameworkElement;

 

cue.Visibility =

Visibility.Collapsed;

 

}

}

 

private void OnRowDropJoinQuery(object sender, DragDropQueryEventArgs e)

 

{

 

var row = sender as GridViewRow;

 

 

var dragCue = e.Options.DragCue as TreeViewDragCue;

 

 

var draggedItems = e.Options.Payload as ICollection;

 

 

//Get the Y displacement ragarding the screen:

 

 

var top = row.TransformToVisual(this).Transform(new Point()).Y;

 

 

var currentPoint = e.Options.CurrentDragPoint;

 

lastRowDropPosition = currentPoint.Y - top < row.ActualHeight / 2 ?

DropPosition.Before : DropPosition.After;

 

 

//Here you can check whether a drop should really be allowed.

 

e.QueryResult = draggedItems.Cast<

object>().All(item => item is SAPTable);

 

e.Handled =

true;

 

}

 

private void OnRowDropQuery(object sender, DragDropQueryEventArgs e)

 

{

 

var row = sender as GridViewRow;

 

 

var dragCue = e.Options.DragCue as TreeViewDragCue;

 

 

var draggedItems = e.Options.Payload as ICollection;

 

 

//Get the Y displacement ragarding the screen:

 

 

var top = row.TransformToVisual(this).Transform(new Point()).Y;

 

 

var currentPoint = e.Options.CurrentDragPoint;

 

lastRowDropPosition = currentPoint.Y - top < row.ActualHeight / 2 ?

DropPosition.Before : DropPosition.After;

 

 

if (draggedItems != null)

 

{

 

//Here you can check whether a drop should really be allowed.

 

e.QueryResult = draggedItems.Cast<

object>().All(item => item is SAPTable);

 

}

e.Handled =

true;

 

}

 

private void OnGridViewDragInfo(object sender, DragDropEventArgs e)

 

{

 

var gridView = sender as RadGridView;

 

 

var draggedItems = e.Options.Payload as IEnumerable;

 

 

if (e.Options.Status == DragStatus.DragInProgress)

 

{

 

this.Dispatcher.BeginInvoke(new Action(() =>

 

{

 

var capturedElement = Mouse.Captured;

 

 

if (capturedElement != null)

 

{

capturedElement.ReleaseMouseCapture();

}

}));

 

//Set up a drag cue:

 

 

var cue = new TreeViewDragCue();

 

 

if (e.Options.Payload != null)

 

{

 

//Here we need to choose a template for the items:

 

 

if (e.Options.Payload.GetType().Name == "SAPJoinClause")

 

{

cue.ItemTemplate =

this.Resources["Product1Template"] as DataTemplate;

 

}

 

else

 

{

cue.ItemTemplate =

this.Resources["ProductTemplate"] as DataTemplate;

 

}

}

cue.ItemsSource = draggedItems;

e.Options.DragCue = cue;

}

 

//else if (e.Options.Status == DragStatus.DragComplete)

 

 

//{

 

 

// var source = gridView.ItemsSource as IList;

 

 

// foreach (object draggedItem in draggedItems)

 

 

// {

 

 

// source.Remove(draggedItem);

 

 

// }

 

 

//}

 

}

 

private void OnDragQuery(object sender, DragDropQueryEventArgs e)

 

{

 

var gridView = sender as RadGridView;

 

 

if (gridView != null)

 

{

 

var selectedItems = gridView.SelectedItems.ToList();

 

e.QueryResult = selectedItems.Count > 0;

 

SAPWhereClause clause = new SAPWhereClause();

 

 

SAPJoinClause clause1 = new SAPJoinClause();

 

 

foreach (SAPSourceFieldInfo item in selectedItems)

 

{

 

if (tabDEEParameters.SelectedIndex == 2)

 

{

 

SAPJoinCond table = new SAPJoinCond(item.PI_ERPTableID, -1, item.TableName, "", item.PI_ERPColumnID, -1, item.ColumnName,

 

 

"", "", "", "", "", -1, "");

 

clause1.Add(table);

}

 

else if (tabDEEParameters.SelectedIndex == 1)

 

{

 

SAPWhereCond table = new SAPWhereCond(item.PI_ERPTableID, item.TableName, item.PI_ERPColumnID,

 

item.ColumnName, -1,

"", "", "", "", "", "", "");

 

clause.Add(table);

}

}

 

if (tabDEEParameters.SelectedIndex == 2)

 

{

e.Options.Payload = clause1;

}

 

else if (tabDEEParameters.SelectedIndex == 1)

 

{

e.Options.Payload = clause;

}

 

}

e.QueryResult =

true;

 

e.Handled =

true;

 

}

 

private void OnGridViewDropJoinInfo(object sender, DragDropEventArgs e)

 

{

 

var destGrid = e.Options.Destination as RadGridView;

 

 

var draggedItems = e.Options.Payload as ICollection;

 

 

// Get the drag cu that the TreeView or we have created

 

 

var cue = e.Options.DragCue as TreeViewDragCue;

 

 

 

if (e.Options.Status == DragStatus.DropPossible)

 

{

 

// Set a suitable text:

 

cue.DragActionContent =

String.Format("Add {0} item{1} to Join Parameters", draggedItems.Count, draggedItems.Count > 1 ? "s" : String.Empty);

 

cue.IsDropPossible =

true;

 

 

if (destGrid != null)

 

{

destGrid.Background =

this.Resources["DropPossibleBackground"] as Brush;

 

}

}

 

else if (e.Options.Status == DragStatus.DropImpossible)

 

{

cue.DragActionContent =

null;

 

cue.IsDropPossible =

false;

 

}

 

else if (e.Options.Status == DragStatus.DropComplete)

 

{

 

var items = grdSrcJoinParameter.ItemsSource as IList;

 

 

foreach (var draggedItem in draggedItems)

 

{

items.Add(draggedItem);

}

grdSrcWhereClause.SelectedItem =

null;

 

grdSrcWhereClause.Rebind();

}

 

if (e.Options.Status != DragStatus.DropPossible)

 

{

 

if (destGrid != null)

 

{

destGrid.Background =

new SolidColorBrush(Colors.White);

 

}

}

 

foreach (var parent in e.Options.Source.GetAncestorsInclusive<UIElement>())

 

{

parent.ReleaseMouseCapture();

}

}

 

private void OnGridViewDropInfo(object sender, DragDropEventArgs e)

 

{

 

var destGrid = e.Options.Destination as RadGridView;

 

 

var draggedItems = e.Options.Payload as ICollection;

 

 

// Get the drag cu that the TreeView or we have created

 

 

var cue = e.Options.DragCue as TreeViewDragCue;

 

 

 

if (e.Options.Status == DragStatus.DropPossible)

 

{

 

// Set a suitable text:

 

cue.DragActionContent =

String.Format("Add {0} item{1} to Conditions", draggedItems.Count, draggedItems.Count > 1 ? "s" : String.Empty);

 

cue.IsDropPossible =

true;

 

 

if (destGrid != null)

 

{

destGrid.Background =

this.Resources["DropPossibleBackground"] as Brush;

 

}

}

 

else if (e.Options.Status == DragStatus.DropImpossible)

 

{

cue.DragActionContent =

null;

 

cue.IsDropPossible =

false;

 

}

 

else if (e.Options.Status == DragStatus.DropComplete)

 

{

 

var items = grdSrcWhereClause.ItemsSource as IList;

 

 

foreach (var draggedItem in draggedItems)

 

{

items.Add(draggedItem);

}

grdSrcWhereClause.SelectedItem =

null;

 

grdSrcWhereClause.Rebind();

}

 

if (e.Options.Status != DragStatus.DropPossible)

 

{

 

if (destGrid != null)

 

{

destGrid.Background =

new SolidColorBrush(Colors.White);

 

}

}

 

foreach (var parent in e.Options.Source.GetAncestorsInclusive<UIElement>())

 

{

parent.ReleaseMouseCapture();

}

}

 

private void OnDropQuery(object sender, DragDropQueryEventArgs e)

 

{

 

// We allow drop only if the dragged items are products:

 

 

var draggedItems = e.Options.Payload as ICollection;

 

 

var result = draggedItems.Cast<object>().All(item => item is SAPWhereCond);

 

e.QueryResult = result;

e.Handled =

true;

 

 

// Note that here we agree to accept a drop. We will be notified

 

 

// in the DropInfo event whether a drop is actually possible.

 

}

 

private void OnDropJoinQuery(object sender, DragDropQueryEventArgs e)

 

{

 

// We allow drop only if the dragged items are products:

 

 

var draggedItems = e.Options.Payload as ICollection;

 

 

var result = draggedItems.Cast<object>().All(item => item is SAPJoinCond);

 

e.QueryResult = result;

e.Handled =

true;

 

 

// Note that here we agree to accept a drop. We will be notified

 

 

// in the DropInfo event whether a drop is actually possible.

 

}


Thanks for your help...

Neha

neha
Top achievements
Rank 1
 answered on 28 Jul 2010
Narrow your results
Selected tags
Tags
GridView
General Discussions
Chart
RichTextBox
Docking
ScheduleView
ChartView
TreeView
Diagram
Map
ComboBox
TreeListView
Window
RibbonView and RibbonWindow
PropertyGrid
DragAndDrop
TabControl
TileView
Carousel
DataForm
PDFViewer
MaskedInput (Numeric, DateTime, Text, Currency)
AutoCompleteBox
DatePicker
Buttons
ListBox
GanttView
PivotGrid
Spreadsheet
Gauges
NumericUpDown
PanelBar
DateTimePicker
DataFilter
Menu
ContextMenu
TimeLine
Calendar
Installer and Visual Studio Extensions
ImageEditor
BusyIndicator
Expander
Slider
TileList
PersistenceFramework
DataPager
Styling
TimeBar
OutlookBar
TransitionControl
FileDialogs
Book
ToolBar
ColorPicker
TimePicker
MultiColumnComboBox
SyntaxEditor
VirtualGrid
Wizard
ExpressionEditor
NavigationView (Hamburger Menu)
WatermarkTextBox
DesktopAlert
BarCode
SpellChecker
DataServiceDataSource
EntityFrameworkDataSource
RadialMenu
ChartView3D
Data Virtualization
BreadCrumb
ProgressBar
Sparkline
LayoutControl
TabbedWindow
ToolTip
CloudUpload
ColorEditor
TreeMap and PivotMap
EntityFrameworkCoreDataSource (.Net Core)
HeatMap
Chat (Conversational UI)
VirtualizingWrapPanel
Calculator
NotifyIcon
TaskBoard
TimeSpanPicker
BulletGraph
Licensing
WebCam
CardView
DataBar
FilePathPicker
PasswordBox
Rating
SplashScreen
Accessibility
Callout
CollectionNavigator
Localization
AutoSuggestBox
Security
VirtualKeyboard
HighlightTextBlock
TouchManager
StepProgressBar
Badge
OfficeNavigationBar
ExpressionParser
CircularProgressBar
SvgImage
PipsPager
SlideView
AI Coding Assistant
+? more
Top users last month
Cynthia
Top achievements
Rank 1
Iron
Jesse
Top achievements
Rank 2
Iron
Toby
Top achievements
Rank 3
Iron
Iron
Iron
Danielle
Top achievements
Rank 1
Iron
Iron
Joel
Top achievements
Rank 3
Bronze
Bronze
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Cynthia
Top achievements
Rank 1
Iron
Jesse
Top achievements
Rank 2
Iron
Toby
Top achievements
Rank 3
Iron
Iron
Iron
Danielle
Top achievements
Rank 1
Iron
Iron
Joel
Top achievements
Rank 3
Bronze
Bronze
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?