or
// 1) Classes that define each of the levels (NodeItem being the base class)
public
class
NodeItem
{
public
string
Name {
get
;
set
; }
public
string
Path {
get
;
set
; }
}
public
class
SourceDirectoryItem : NodeItem
{
public
SourceDirectoryItem()
{
this
.Children =
new
ObservableCollection<NodeItem>();
}
public
ObservableCollection<NodeItem> Children {
get
;
set
; }
}
public
class
SourceFileItem : NodeItem
{
public
SourceFileItem()
{
this
.Functions =
new
ObservableCollection<NodeItem>();
}
public
ObservableCollection<NodeItem> Functions {
get
;
set
; }
}
public
class
FunctionItem : NodeItem
{
}
// 2) XAML
<telerik:RadTreeListView
AutoGenerateColumns=
"False"
ItemsSource=
"{Binding Nodes}"
>
<telerik:RadTreeListView.ChildTableDefinitions>
<telerik:TreeListViewTableDefinition ItemsSource=
"{Binding Children}"
>
<telerik:TreeListViewTableDefinition.ChildTableDefinitions>
<telerik:TreeListViewTableDefinition ItemsSource=
"{Binding Children}"
>
<telerik:TreeListViewTableDefinition ItemsSource=
"{Binding Functions}"
/>
</telerik:TreeListViewTableDefinition>
</telerik:TreeListViewTableDefinition.ChildTableDefinitions>
</telerik:TreeListViewTableDefinition>
</telerik:RadTreeListView.ChildTableDefinitions>
<telerik:RadTreeListView.Columns>
<telerik:GridViewDataColumn DataMemberBinding=
"{Binding Name}"
Header=
"NAME"
>
</telerik:GridViewDataColumn>
</telerik:RadTreeListView.Columns>
</telerik:RadTreeListView>
// 3) In the VM there is nothing special, this is how I populate the nodes:
private
void
InitNodes()
{
SourceDirectoryItem root =
new
SourceDirectoryItem() { Name =
"c:\\"
, Path = Name };
SourceDirectoryItem firstLevel =
new
SourceDirectoryItem() { Name =
"c:\\folder1"
, Path = Name };
SourceDirectoryItem secondLevel01 =
new
SourceDirectoryItem() { Name =
"c:\\folder1\\temp"
, Path = Name };
SourceDirectoryItem secondLevel02 =
new
SourceDirectoryItem() { Name =
"c:\\folder1\\programfiles"
, Path = Name };
firstLevel.Children.Add(secondLevel01);
firstLevel.Children.Add(secondLevel02);
root.Children.Add(firstLevel);
SourceFileItem sf =
new
SourceFileItem();
sf.Name =
"foo.cs"
;
sf.Path =
"c:\\temp"
;
sf.Functions.Add(
new
FunctionItem() { Name =
"Method001"
});
sf.Functions.Add(
new
FunctionItem() { Name =
"Method002"
});
sf.Functions.Add(
new
FunctionItem() { Name =
"Method003"
});
secondLevel01.Children.Add(sf);
SourceFileItem sf1 =
new
SourceFileItem();
sf1.Name =
"bar.cs"
;
sf1.Path =
"c:\\programfiles"
;
sf1.Functions.Add(
new
FunctionItem() { Name =
"AnotherMethod"
});
secondLevel02.Children.Add(sf1);
this
.Nodes.Add(root);
}
private
ObservableCollection<NodeItem> nodes;
public
ObservableCollection<NodeItem> Nodes
{
get
{
return
this
.nodes;
}
set
{
this
.nodes = value;
this
.OnPropertyChanged(
"Nodes"
);
}
}
internal
WndMain()
{
InitializeComponent()
this
.GridViewLocalizations.MouseMove +=
new
MouseEventHandler(GridViewLocalizations_MouseMove);
}
void
GridViewLocalizations_MouseMove(
object
sender, MouseEventArgs e)
{
}
"GridViewLocalizations_MouseMove
" does not get called on moving the mouse over the GridView. Why?
How can I trap MouseMove events on a GridView?
And why can't I write outside of this code block anyway?? Man, Telerik sometimes...
public
static
class
RadSchedule
{
public
static
bool
GetEnsureVisibilityOfSelectedAppointments(DependencyObject obj)
{
return
(
bool
)obj.GetValue(EnsureVisibilityOfSelectedAppointmentsProperty);
}
public
static
void
SetEnsureVisibilityOfSelectedAppointments(DependencyObject obj,
bool
value)
{
obj.SetValue(EnsureVisibilityOfSelectedAppointmentsProperty, value);
}
public
static
readonly
DependencyProperty EnsureVisibilityOfSelectedAppointmentsProperty =
DependencyProperty.RegisterAttached(
"EnsureVisibilityOfSelectedAppointments"
,
typeof
(
bool
),
typeof
(RadSchedule),
new
UIPropertyMetadata(
false
, EnsureVisibilityChanged));
private
static
void
EnsureVisibilityChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
if
(d ==
null
)
{
throw
new
ArgumentNullException(
"d"
);
}
var view = d
as
RadScheduleView;
if
(view ==
null
)
{
throw
new
NotSupportedException(
"This attached behavior can only be set on a Telerik RadScheduleView."
);
}
var shouldEnsureVisibility = (
bool
)e.NewValue;
if
(shouldEnsureVisibility)
{
view.AppointmentSelectionChanged += view_AppointmentSelectionChanged;
}
else
{
view.AppointmentSelectionChanged -= view_AppointmentSelectionChanged;
}
}
static
void
view_AppointmentSelectionChanged(
object
sender, System.Windows.Controls.SelectionChangedEventArgs e)
{
if
(sender ==
null
)
{
throw
new
ArgumentNullException(
"sender"
);
}
var view = sender
as
RadScheduleView;
if
(view ==
null
)
{
throw
new
NotSupportedException(
"This attached behavior can only be set on a Telerik RadScheduleView."
);
}
if
(view.SelectedAppointment ==
null
)
{
return
;
}
view.ScrollIntoView(view.SelectedAppointment,
true
);
// According to http://www.telerik.com/community/forums/wpf/scheduleview/scrollntoview-not-working.aspx,
// this should have solved this issue:
view.CurrentDate = view.SelectedAppointment.Start.Date;
}
}
<
UserControl.DataContext
>
<
DutyRegulations:DutyRegulationsViewModel
/>
</
UserControl.DataContext
>
<
UserControl.Resources
>
<
DataTemplate
x:Key
=
"TabContentTemplate"
>
<
Grid
>
<
Grid.ColumnDefinitions
>
<
ColumnDefinition
Width
=
"*"
/>
</
Grid.ColumnDefinitions
>
<
telerik:RadRichTextBox
x:Name
=
"radRichTextBox"
IsReadOnly
=
"True"
Grid.Column
=
"0"
Width
=
"500"
Height
=
"500"
/>
<
Rtf:RtfDataProvider
Rtf
=
"{Binding FileSource}"
RichTextBox
=
"{Binding ElementName=radRichTextBox}"
/>
</
Grid
>
</
DataTemplate
>
</
UserControl.Resources
>
<
Grid
>
<
telerik:RadTabControl
HorizontalAlignment
=
"Stretch"
Name
=
"radTabControl"
VerticalAlignment
=
"Stretch"
ItemsSource
=
"{Binding Path=StaffDutyRegulations}"
DisplayMemberPath
=
"Staff.Name"
ContentTemplate
=
"{StaticResource TabContentTemplate}"
/>
</
Grid
>