I am trying to get RadTreeListView cell contents to be aligned with the top of the cell, in both view and edit modes. Currently I'm doing this with implicit styles for GridViewCell and GridViewEditorPresenter. This works until I apply the Windows7 theme, then it just seems to ignore the GridViewEditorPresenter implicit style.
Here is my code. What am I doing wrong?
MainPage.xaml:
MainPage.xaml.cs:
Here is my code. What am I doing wrong?
MainPage.xaml:
<
UserControl
x:Class
=
"AlignTop.MainPage"
xmlns:telerik
=
"http://schemas.telerik.com/2008/xaml/presentation"
mc:Ignorable
=
"d"
d:DesignHeight
=
"300"
d:DesignWidth
=
"400"
>
<
UserControl.Resources
>
<
Style
TargetType
=
"telerik:GridViewCell"
>
<
Setter
Property
=
"VerticalContentAlignment"
Value
=
"Top"
/>
</
Style
>
<
Style
TargetType
=
"telerik:GridViewEditorPresenter"
>
<
Setter
Property
=
"VerticalContentAlignment"
Value
=
"Stretch"
/>
</
Style
>
</
UserControl.Resources
>
<
Grid
x:Name
=
"LayoutRoot"
Background
=
"White"
>
<
telerik:RadTreeListView
x:Name
=
"Tree"
ItemsSource
=
"{Binding Items}"
AlternationCount
=
"2"
AlternateRowBackground
=
"#F1F4F8"
AutoGenerateColumns
=
"False"
CanUserFreezeColumns
=
"False"
EnableRowVirtualization
=
"True"
EnableColumnVirtualization
=
"True"
GridLinesVisibility
=
"None"
RowIndicatorVisibility
=
"Collapsed"
>
<
telerik:RadTreeListView.ChildTableDefinitions
>
<
telerik:TreeListViewTableDefinition
ItemsSource
=
"{Binding Items}"
/>
</
telerik:RadTreeListView.ChildTableDefinitions
>
<
telerik:RadTreeListView.Columns
>
<
telerik:GridViewDataColumn
UniqueName
=
"Name"
DataMemberBinding
=
"{Binding Name}"
/>
<
telerik:GridViewDataColumn
UniqueName
=
"Description"
DataMemberBinding
=
"{Binding Description}"
Width
=
"300"
>
<
telerik:GridViewColumn.CellTemplate
>
<
DataTemplate
>
<
TextBlock
Text
=
"{Binding Description}"
TextWrapping
=
"Wrap"
/>
</
DataTemplate
>
</
telerik:GridViewColumn.CellTemplate
>
<
telerik:GridViewColumn.CellEditTemplate
>
<
DataTemplate
>
<
TextBox
Text
=
"{Binding Description}"
TextWrapping
=
"Wrap"
/>
</
DataTemplate
>
</
telerik:GridViewColumn.CellEditTemplate
>
</
telerik:GridViewDataColumn
>
</
telerik:RadTreeListView.Columns
>
</
telerik:RadTreeListView
>
</
Grid
>
</
UserControl
>
MainPage.xaml.cs:
using
System.Collections.Generic;
using
System.Windows.Controls;
using
Telerik.Windows.Controls;
namespace
AlignTop
{
public
partial
class
MainPage : UserControl
{
private
const
string
_loremIpsum =
"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
;
public
MainPage()
{
StyleManager.ApplicationTheme =
new
Windows7Theme();
InitializeComponent();
Tree.DataContext =
this
;
}
private
IEnumerable<Item> _items;
public
IEnumerable<Item> Items
{
get
{
if
(_items ==
null
)
{
Item item1 =
new
Item { Name =
"Item1"
, Description = _loremIpsum };
Item item2 =
new
Item { Name =
"Item2"
, Description = _loremIpsum };
Item item3 =
new
Item { Name =
"Item3"
, Description = _loremIpsum, Items =
new
List<Item> { item1, item2 } };
Item item4 =
new
Item { Name =
"Item4"
, Description = _loremIpsum };
Item item5 =
new
Item { Name =
"Item5"
, Description = _loremIpsum };
Item item6 =
new
Item { Name =
"Item6"
, Description = _loremIpsum, Items =
new
List<Item> { item4, item5 } };
Item item7 =
new
Item { Name =
"Item7"
, Description = _loremIpsum };
_items =
new
List<Item> { item3, item6, item7 };
}
return
_items;
}
}
}
public
class
Item
{
public
string
Name {
get
;
set
; }
public
string
Description {
get
;
set
; }
public
IEnumerable<Item> Items {
get
;
set
; }
}
}