using System.Windows;
using System.Collections.ObjectModel;
using DevExpress.Xpf.Core;
namespace How_to_Customize_Drop_Marker {
public partial class MainWindow : Window {
public class Employee {
public int ID { get; set; }
public int ParentID { get; set; }
public string Name { get; set; }
public string Position { get; set; }
public string Department { get; set; }
public override string ToString() {
return Name;
}
}
public static class Stuff {
public static ObservableCollection<Employee> GetStuff() {
ObservableCollection<Employee> stuff = new ObservableCollection<Employee>();
stuff.Add(new Employee() { ID = 1, ParentID = 0, Name = "Gregory S. Price", Department = "", Position = "President" });
stuff.Add(new Employee() { ID = 2, ParentID = 1, Name = "Irma R. Marshall", Department = "Marketing", Position = "Vice President" });
stuff.Add(new Employee() { ID = 3, ParentID = 1, Name = "John C. Powell", Department = "Operations", Position = "Vice President" });
stuff.Add(new Employee() { ID = 4, ParentID = 1, Name = "Christian P. Laclair", Department = "Production", Position = "Vice President" });
stuff.Add(new Employee() { ID = 5, ParentID = 1, Name = "Karen J. Kelly", Department = "Finance", Position = "Vice President" });
stuff.Add(new Employee() { ID = 6, ParentID = 2, Name = "Brian C. Cowling", Department = "Marketing", Position = "Manager" });
stuff.Add(new Employee() { ID = 7, ParentID = 2, Name = "Thomas C. Dawson", Department = "Marketing", Position = "Manager" });
stuff.Add(new Employee() { ID = 8, ParentID = 2, Name = "Angel M. Wilson", Department = "Marketing", Position = "Manager" });
stuff.Add(new Employee() { ID = 9, ParentID = 2, Name = "Bryan R. Henderson", Department = "Marketing", Position = "Manager" });
stuff.Add(new Employee() { ID = 10, ParentID = 3, Name = "Harold S. Brandes", Department = "Operations", Position = "Manager" });
stuff.Add(new Employee() { ID = 11, ParentID = 3, Name = "Michael S. Blevins", Department = "Operations", Position = "Manager" });
stuff.Add(new Employee() { ID = 12, ParentID = 3, Name = "Jan K. Sisk", Department = "Operations", Position = "Manager" });
stuff.Add(new Employee() { ID = 13, ParentID = 3, Name = "Sidney L. Holder", Department = "Operations", Position = "Manager" });
stuff.Add(new Employee() { ID = 14, ParentID = 4, Name = "James L. Kelsey", Department = "Production", Position = "Manager" });
stuff.Add(new Employee() { ID = 15, ParentID = 4, Name = "Howard M. Carpenter", Department = "Production", Position = "Manager" });
stuff.Add(new Employee() { ID = 16, ParentID = 4, Name = "Jennifer T. Tapia", Department = "Production", Position = "Manager" });
stuff.Add(new Employee() { ID = 17, ParentID = 5, Name = "Judith P. Underhill", Department = "Finance", Position = "Manager" });
stuff.Add(new Employee() { ID = 18, ParentID = 5, Name = "Russell E. Belton", Department = "Finance", Position = "Manager" });
return stuff;
}
}
public MainWindow() {
InitializeComponent();
gridControl.ItemsSource = Stuff.GetStuff();
}
}
}
using System;
using System.Windows.Data;
using System.Globalization;
using DevExpress.Xpf.Core;
using System.Windows;
namespace How_to_Customize_Drop_Marker {
public class InternalMarkerVisibilityConverter : IValueConverter {
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) {
if ((DropPosition)value == DropPosition.Inside)
return Visibility.Visible;
else
return Visibility.Collapsed;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) {
throw new NotImplementedException();
}
}
public class ExternalMarkerVisibilityConverter : IValueConverter {
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) {
if ((DropPosition)value == DropPosition.Before || (DropPosition)value == DropPosition.After)
return Visibility.Visible;
else
return Visibility.Collapsed;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) {
throw new NotImplementedException();
}
}
public class VerticalAlignmentConverter : IValueConverter {
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) {
if ((DropPosition)value == DropPosition.Before)
return VerticalAlignment.Top;
else
return VerticalAlignment.Bottom;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) {
throw new NotImplementedException();
}
}
}
<Window x:Class="How_to_Customize_Drop_Marker.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core"
xmlns:dxc="http://schemas.devexpress.com/winfx/2008/xaml/core"
xmlns:dxg="http://schemas.devexpress.com/winfx/2008/xaml/grid"
xmlns:dxmvvm="http://schemas.devexpress.com/winfx/2008/xaml/mvvm"
xmlns:local="clr-namespace:How_to_Customize_Drop_Marker"
Title="MainWindow" Height="350" Width="525">
<Window.Resources>
<local:InternalMarkerVisibilityConverter x:Key="internalMarkerVisibilityConverter" />
<local:ExternalMarkerVisibilityConverter x:Key="externalMarkerVisibilityConverter" />
<local:VerticalAlignmentConverter x:Key="verticalAlignmentConverter" />
</Window.Resources>
<Grid>
<dxg:GridControl Name="gridControl" SelectionMode="Row">
<dxg:GridControl.Columns>
<dxg:GridColumn FieldName="Name" ReadOnly="True"/>
<dxg:GridColumn FieldName="Department" ReadOnly="True"/>
<dxg:GridColumn FieldName="Position" ReadOnly="True"/>
</dxg:GridControl.Columns>
<dxg:GridControl.View>
<dxg:TreeListView KeyFieldName="ID" ParentFieldName="ParentID"
AutoExpandAllNodes="True" AllowDragDrop="True">
<dxg:TreeListView.DropMarkerTemplate>
<DataTemplate>
<Grid Margin="{Binding Padding}" IsHitTestVisible="False">
<Border Background="Orange" Opacity="0.2" Visibility="{Binding Position,
Converter={StaticResource internalMarkerVisibilityConverter}}" />
<Grid Margin="0,-3,0,-3" Visibility="{Binding Position,
Converter={StaticResource externalMarkerVisibilityConverter}}">
<Border Height="6" Background="Orange" BorderBrush="Gray" BorderThickness="1"
VerticalAlignment="{Binding Position,
Converter={StaticResource verticalAlignmentConverter}}" />
</Grid>
</Grid>
</DataTemplate>
</dxg:TreeListView.DropMarkerTemplate>
</dxg:TreeListView>
</dxg:GridControl.View>
</dxg:GridControl>
</Grid>
</Window>
Imports System
Imports System.Windows.Data
Imports System.Globalization
Imports DevExpress.Xpf.Core
Imports System.Windows
Namespace How_to_Customize_Drop_Marker
Public Class InternalMarkerVisibilityConverter
Implements IValueConverter
Public Function Convert(ByVal value As Object, ByVal targetType As Type, ByVal parameter As Object, ByVal culture As CultureInfo) As Object Implements IValueConverter.Convert
If DirectCast(value, DropPosition) = DropPosition.Inside Then
Return Visibility.Visible
Else
Return Visibility.Collapsed
End If
End Function
Public Function ConvertBack(ByVal value As Object, ByVal targetType As Type, ByVal parameter As Object, ByVal culture As CultureInfo) As Object Implements IValueConverter.ConvertBack
Throw New NotImplementedException()
End Function
End Class
Public Class ExternalMarkerVisibilityConverter
Implements IValueConverter
Public Function Convert(ByVal value As Object, ByVal targetType As Type, ByVal parameter As Object, ByVal culture As CultureInfo) As Object Implements IValueConverter.Convert
If DirectCast(value, DropPosition) = DropPosition.Before OrElse DirectCast(value, DropPosition) = DropPosition.After Then
Return Visibility.Visible
Else
Return Visibility.Collapsed
End If
End Function
Public Function ConvertBack(ByVal value As Object, ByVal targetType As Type, ByVal parameter As Object, ByVal culture As CultureInfo) As Object Implements IValueConverter.ConvertBack
Throw New NotImplementedException()
End Function
End Class
Public Class VerticalAlignmentConverter
Implements IValueConverter
Public Function Convert(ByVal value As Object, ByVal targetType As Type, ByVal parameter As Object, ByVal culture As CultureInfo) As Object Implements IValueConverter.Convert
If DirectCast(value, DropPosition) = DropPosition.Before Then
Return VerticalAlignment.Top
Else
Return VerticalAlignment.Bottom
End If
End Function
Public Function ConvertBack(ByVal value As Object, ByVal targetType As Type, ByVal parameter As Object, ByVal culture As CultureInfo) As Object Implements IValueConverter.ConvertBack
Throw New NotImplementedException()
End Function
End Class
End Namespace
Imports System.Windows
Imports System.Collections.ObjectModel
Imports DevExpress.Xpf.Core
Namespace How_to_Customize_Drop_Marker
Partial Public Class MainWindow
Inherits Window
Public Class Employee
Public Property ID() As Integer
Public Property ParentID() As Integer
Public Property Name() As String
Public Property Position() As String
Public Property Department() As String
Public Overrides Function ToString() As String
Return Name
End Function
End Class
Public NotInheritable Class Stuff
Private Sub New()
End Sub
Public Shared Function GetStuff() As ObservableCollection(Of Employee)
Dim stuff_Renamed As New ObservableCollection(Of Employee)()
stuff_Renamed.Add(New Employee() With { _
.ID = 1, _
.ParentID = 0, _
.Name = "Gregory S. Price", _
.Department = "", _
.Position = "President" _
})
stuff_Renamed.Add(New Employee() With { _
.ID = 2, _
.ParentID = 1, _
.Name = "Irma R. Marshall", _
.Department = "Marketing", _
.Position = "Vice President" _
})
stuff_Renamed.Add(New Employee() With { _
.ID = 3, _
.ParentID = 1, _
.Name = "John C. Powell", _
.Department = "Operations", _
.Position = "Vice President" _
})
stuff_Renamed.Add(New Employee() With { _
.ID = 4, _
.ParentID = 1, _
.Name = "Christian P. Laclair", _
.Department = "Production", _
.Position = "Vice President" _
})
stuff_Renamed.Add(New Employee() With { _
.ID = 5, _
.ParentID = 1, _
.Name = "Karen J. Kelly", _
.Department = "Finance", _
.Position = "Vice President" _
})
stuff_Renamed.Add(New Employee() With { _
.ID = 6, _
.ParentID = 2, _
.Name = "Brian C. Cowling", _
.Department = "Marketing", _
.Position = "Manager" _
})
stuff_Renamed.Add(New Employee() With { _
.ID = 7, _
.ParentID = 2, _
.Name = "Thomas C. Dawson", _
.Department = "Marketing", _
.Position = "Manager" _
})
stuff_Renamed.Add(New Employee() With { _
.ID = 8, _
.ParentID = 2, _
.Name = "Angel M. Wilson", _
.Department = "Marketing", _
.Position = "Manager" _
})
stuff_Renamed.Add(New Employee() With { _
.ID = 9, _
.ParentID = 2, _
.Name = "Bryan R. Henderson", _
.Department = "Marketing", _
.Position = "Manager" _
})
stuff_Renamed.Add(New Employee() With { _
.ID = 10, _
.ParentID = 3, _
.Name = "Harold S. Brandes", _
.Department = "Operations", _
.Position = "Manager" _
})
stuff_Renamed.Add(New Employee() With { _
.ID = 11, _
.ParentID = 3, _
.Name = "Michael S. Blevins", _
.Department = "Operations", _
.Position = "Manager" _
})
stuff_Renamed.Add(New Employee() With { _
.ID = 12, _
.ParentID = 3, _
.Name = "Jan K. Sisk", _
.Department = "Operations", _
.Position = "Manager" _
})
stuff_Renamed.Add(New Employee() With { _
.ID = 13, _
.ParentID = 3, _
.Name = "Sidney L. Holder", _
.Department = "Operations", _
.Position = "Manager" _
})
stuff_Renamed.Add(New Employee() With { _
.ID = 14, _
.ParentID = 4, _
.Name = "James L. Kelsey", _
.Department = "Production", _
.Position = "Manager" _
})
stuff_Renamed.Add(New Employee() With { _
.ID = 15, _
.ParentID = 4, _
.Name = "Howard M. Carpenter", _
.Department = "Production", _
.Position = "Manager" _
})
stuff_Renamed.Add(New Employee() With { _
.ID = 16, _
.ParentID = 4, _
.Name = "Jennifer T. Tapia", _
.Department = "Production", _
.Position = "Manager" _
})
stuff_Renamed.Add(New Employee() With { _
.ID = 17, _
.ParentID = 5, _
.Name = "Judith P. Underhill", _
.Department = "Finance", _
.Position = "Manager" _
})
stuff_Renamed.Add(New Employee() With { _
.ID = 18, _
.ParentID = 5, _
.Name = "Russell E. Belton", _
.Department = "Finance", _
.Position = "Manager" _
})
Return stuff_Renamed
End Function
End Class
Public Sub New()
InitializeComponent()
gridControl.ItemsSource = Stuff.GetStuff()
End Sub
End Class
End Namespace