or
RowStyle="{DynamicResource TopGridRow}"
AlternateRowStyle="{DynamicResource TopGridAlternateRow}"
HeaderRowStyle="{DynamicResource TopGridHeaderRow}"
VerticalGridLinesBrush="{DynamicResource TopGridVerticalBrush}"
HorizontalGridLinesBrush="{DynamicResource TopGridHorizontalBrush}"
telerik:Theming.Theme="Vista"
<
telerik:GridViewComboBoxColumn
UniqueName
=
"cmbActionBy"
IsComboBoxEditable
=
"True"
Header
=
"Action by"
DataMemberBinding
=
"{Binding Path=tblContact}"
telerik:TextSearch.TextPath
=
"ShortName"
DisplayMemberPath
=
"ShortName"
Width
=
"80"
SortMemberPath
=
"tblContact.ShortName"
EditorStyle
=
"{Binding Source={StaticResource MyStyle}}"
>
<
Style
x:Key
=
"MyStyle"
TargetType
=
"telerik:RadComboBox"
>
<
Setter
Property
=
"ItemTemplate"
>
<
Setter.Value
>
<
DataTemplate
>
<
StackPanel
Orientation
=
"Vertical"
VerticalAlignment
=
"Center"
>
<
TextBlock
Text
=
"{Binding Path=Name}"
TextAlignment
=
"Left"
HorizontalAlignment
=
"Left"
/>
<
TextBlock
Text
=
"{Binding Path=ShortName}"
TextAlignment
=
"Right"
HorizontalAlignment
=
"Right"
Margin
=
"5,0,0,0"
/>
</
StackPanel
>
</
DataTemplate
>
</
Setter.Value
>
</
Setter
>
</
Style
>
I thought I had everything going well with my rad datepicker column from an autogenerated columns radgridview (chosen using a template selector), and it works well, except that when I add the row, it is cleared, and the user must then edit the column in the grid to reselect the date.
I think that to solve this both datatemplates for my date column (cell edit template, and cell template) must have the same binding (one is text the other rad datepicker control).
Unfortunately I cant seem to bind the RadDatePicker control's selected value to anything in my view model, without getting the error
property not found on 'object' ''DataRowView'
productionSeriesMapping.SeriesDefinition.InteractivitySettings.HoverScope = InteractivityScope.Series
<
UserControl
xmlns:telerik
=
"http://schemas.telerik.com/2008/xaml/presentation"
x:Class
=
"WpfApplication5.GettingStarted"
mc:Ignorable
=
"d"
d:DesignHeight
=
"300"
d:DesignWidth
=
"300"
>
<
UserControl.Resources
>
<
DataTemplate
x:Key
=
"ApplicationDragTemplate"
>
<
Image
Source
=
"{Binding IconPath}"
Stretch
=
"None"
VerticalAlignment
=
"Top"
/>
</
DataTemplate
>
<
Style
TargetType
=
"ListBoxItem"
x:Key
=
"draggableItemStyle"
>
<
Setter
Property
=
"HorizontalContentAlignment"
Value
=
"Stretch"
/>
<
Setter
Property
=
"telerik:RadDragAndDropManager.AllowDrag"
Value
=
"True"
/>
</
Style
>
</
UserControl.Resources
>
<
Grid
x:Name
=
"LayoutRoot"
Background
=
"White"
>
<
Grid.ColumnDefinitions
>
<
ColumnDefinition
Width
=
"200"
/>
<
ColumnDefinition
Width
=
"150"
/>
<
ColumnDefinition
Width
=
"200"
/>
</
Grid.ColumnDefinitions
>
<
ListBox
x:Name
=
"allApplicationsBox"
telerik:RadDragAndDropManager.AllowDrop
=
"True"
ItemContainerStyle
=
"{StaticResource draggableItemStyle}"
>
<
ListBox.ItemTemplate
>
<
DataTemplate
>
<
Grid
Width
=
"150"
>
<
Grid.RowDefinitions
>
<
RowDefinition
/>
<
RowDefinition
/>
<
RowDefinition
/>
</
Grid.RowDefinitions
>
<
Image
Grid.Row
=
"0"
HorizontalAlignment
=
"Center"
Source
=
"{Binding IconPath}"
Width
=
"32"
Height
=
"32"
Margin
=
"0 0 5 0"
/>
<
TextBlock
Grid.Row
=
"1"
Text
=
"{Binding Name}"
FontWeight
=
"Bold"
HorizontalAlignment
=
"Center"
/>
<
TextBlock
Text
=
"{Binding Author}"
Grid.Row
=
"2"
HorizontalAlignment
=
"Center"
/>
</
Grid
>
</
DataTemplate
>
</
ListBox.ItemTemplate
>
</
ListBox
>
<!--My Applications-->
<
ListBox
x:Name
=
"myApplicationsBox"
telerik:RadDragAndDropManager.AllowDrop
=
"True"
ItemContainerStyle
=
"{StaticResource draggableItemStyle}"
Grid.Column
=
"2"
>
<
ListBox.ItemTemplate
>
<
DataTemplate
>
<
StackPanel
VerticalAlignment
=
"Stretch"
HorizontalAlignment
=
"Stretch"
>
<
Image
Source
=
"{Binding IconPath}"
Margin
=
"0 0 3 0"
HorizontalAlignment
=
"Center"
/>
<
TextBlock
Text
=
"{Binding Name}"
HorizontalAlignment
=
"Center"
/>
</
StackPanel
>
</
DataTemplate
>
</
ListBox.ItemTemplate
>
<
ListBox.ItemsPanel
>
<
ItemsPanelTemplate
>
<
telerik:RadUniformGrid
Columns
=
"3"
HorizontalAlignment
=
"Left"
VerticalAlignment
=
"Top"
/>
</
ItemsPanelTemplate
>
</
ListBox.ItemsPanel
>
</
ListBox
>
</
Grid
>
</
UserControl
>
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Text;
using
System.Windows;
using
System.Windows.Controls;
using
System.Windows.Data;
using
System.Windows.Documents;
using
System.Windows.Input;
using
System.Windows.Media;
using
System.Windows.Media.Imaging;
using
System.Windows.Navigation;
using
System.Windows.Shapes;
using
System.Collections.ObjectModel;
using
Telerik.Windows.Controls.DragDrop;
using
Telerik.Windows.Controls;
namespace
WpfApplication5
{
public
class
ApplicationInfo
{
public
ApplicationInfo(
string
iconPath,
string
name,
string
author)
{
this
.IconPath = iconPath;
this
.Name = name;
this
.Author = author;
}
public
String IconPath
{
get
;
set
;
}
public
String Name
{
get
;
set
;
}
public
String Author
{
get
;
set
;
}
}
public
partial
class
GettingStarted : UserControl
{
public
static
ObservableCollection<ApplicationInfo> GenerateApplicationInfos()
{
ObservableCollection<ApplicationInfo> data =
new
ObservableCollection<ApplicationInfo>();
for
(
int
i = 1; i <= 5; i++)
{
data.Add(
new
ApplicationInfo(
"Images/nature"
+ i +
".jpg"
,
"Nome"
+ i,
"Autore"
+ 1));
}
return
data;
}
private
ObservableCollection<ApplicationInfo> allApplications = GenerateApplicationInfos();
private
ObservableCollection<ApplicationInfo> myApplications =
new
ObservableCollection<ApplicationInfo>();
public
GettingStarted()
{
InitializeComponent();
allApplicationsBox.ItemsSource = allApplications;
myApplicationsBox.ItemsSource = myApplications;
RadDragAndDropManager.AddDragQueryHandler(
this
, OnDragQuery);
RadDragAndDropManager.AddDragInfoHandler(
this
, OnDragInfo);
RadDragAndDropManager.AddDropQueryHandler(
this
, OnDropQuery);
RadDragAndDropManager.AddDropInfoHandler(
this
, OnDropInfo);
}
// OnDragQuery event handler
private
void
OnDragQuery(
object
sender, DragDropQueryEventArgs e)
{
ListBoxItem listBoxItem = e.Options.Source
as
ListBoxItem;
ListBox box = ItemsControl.ItemsControlFromItemContainer(listBoxItem)
as
ListBox;
if
(e.Options.Status == DragStatus.DragQuery && box !=
null
)
{
e.Options.Payload = box.SelectedItem;
ContentControl cue =
new
ContentControl();
cue.ContentTemplate =
this
.Resources[
"ApplicationDragTemplate"
]
as
DataTemplate;
cue.Content = box.SelectedItem;
e.Options.DragCue = cue;
e.Options.ArrowCue = RadDragAndDropManager.GenerateArrowCue();
}
e.QueryResult =
true
;
}
// OnDropQuery event handler
private
void
OnDropQuery(
object
sender, DragDropQueryEventArgs e)
{
ItemsControl box = e.Options.Destination
as
ItemsControl;
IList<ApplicationInfo> itemsSource = box.ItemsSource
as
IList<ApplicationInfo>;
ApplicationInfo payload = e.Options.Payload
as
ApplicationInfo;
e.QueryResult = payload !=
null
&& !itemsSource.Contains(payload);
}
// OnDropInfo event handler
private
void
OnDropInfo(
object
sender, DragDropEventArgs e)
{
ItemsControl box = e.Options.Destination
as
ItemsControl;
IList<ApplicationInfo> itemsSource = box.ItemsSource
as
IList<ApplicationInfo>;
ApplicationInfo payload = e.Options.Payload
as
ApplicationInfo;
if
(e.Options.Status == DragStatus.DropComplete)
if
(!itemsSource.Contains(payload))
itemsSource.Add(payload);
}
// OnDragInfo event handler
private
void
OnDragInfo(
object
sender, DragDropEventArgs e)
{
ListBoxItem listBoxItem = e.Options.Source
as
ListBoxItem;
ListBox box = ItemsControl.ItemsControlFromItemContainer(listBoxItem)
as
ListBox;
IList<ApplicationInfo> itemsSource = box.ItemsSource
as
IList<ApplicationInfo>;
ApplicationInfo payload = e.Options.Payload
as
ApplicationInfo;
if
(e.Options.Status == DragStatus.DragComplete)
{
if
(payload !=
null
&& itemsSource.Contains(payload))
{
itemsSource.Remove(payload);
}
}
}
}
}
private
void
MyGrid_RowIsExpandedChanged(
object
sender, RowEventArgs e)
{
if
(changing)
return
;
this
.changing =
true
;
if
((e.Row
as
GridViewRow).IsExpanded)
{
this
.MyGrid.CollapseAllHierarchyItems();
this
.MyGrid.ExpandHierarchyItem(e.Row.DataContext);
}
this
.changing =
false
;
}
private
void
AttributesGrid_MouseDoubleClick(
object
sender, System.Windows.Input.MouseButtonEventArgs e)
{
ExpandHierarchyItem((RadGridView)sender);
}
private
void
ExpandHierarchyItem(RadGridView sender)
{
sender.CollapseAllHierarchyItems();
sender.ExpandHierarchyItem(sender.SelectedItem);
}
private
void
MyGrid_BeginningEdit(
object
sender, GridViewBeginningEditRoutedEventArgs e)
{
ExpandHierarchyItem((RadGridView)sender);
}