or
System.Windows.Data Error: 25 : Both 'ContentTemplate' and 'ContentTemplateSelector' are set; 'ContentTemplateSelector' will be ignored. ContentPresenter:'ContentPresenter' (Name='')
Why PropertyGrid generate excess properties, when AutoGeneratePropertyDefinitions is set to false?
<
Window
x:Class
=
"PropertyGridTester.MainWindow"
xmlns:PropertyGridTester
=
"clr-namespace:PropertyGridTester"
xmlns:telerik
=
"http://schemas.telerik.com/2008/xaml/presentation"
Title
=
"MainWindow"
Height
=
"350"
Width
=
"525"
mc:Ignorable
=
"d"
d:DataContext
=
"{d:DesignInstance {x:Type PropertyGridTester:MainWindowViewModel}}"
>
<
Grid
>
<
Grid.ColumnDefinitions
>
<
ColumnDefinition
Width
=
"Auto"
/>
<
ColumnDefinition
Width
=
"*"
/>
</
Grid.ColumnDefinitions
>
<
StackPanel
Grid.Column
=
"0"
>
<
RadioButton
Command
=
"{Binding SetFirstClass}"
>Set first class</
RadioButton
>
<
RadioButton
Command
=
"{Binding SetSecondClass}"
>Set second class</
RadioButton
>
<
RadioButton
Command
=
"{Binding SetNull}"
IsChecked
=
"True"
>Set null</
RadioButton
>
</
StackPanel
>
<
ContentControl
Grid.Column
=
"1"
DataContext
=
"{Binding SelectedClass}"
Content
=
"{Binding}"
>
<
ContentControl.Resources
>
<
DataTemplate
DataType
=
"{x:Type PropertyGridTester:FirstClass}"
>
<
telerik:RadPropertyGrid
Item
=
"{Binding}"
AutoGeneratePropertyDefinitions
=
"False"
HorizontalAlignment
=
"Stretch"
SearchBoxVisibility
=
"Collapsed"
SortAndGroupButtonsVisibility
=
"Collapsed"
DescriptionPanelVisibility
=
"Collapsed"
HorizontalContentAlignment
=
"Stretch"
LabelColumnWidth
=
"110"
>
<
telerik:RadPropertyGrid.PropertyDefinitions
>
<
telerik:PropertyDefinition
Binding
=
"{Binding Visible}"
DisplayName
=
"First class visible"
>
<
telerik:PropertyDefinition.EditorTemplate
>
<
DataTemplate
>
<
TextBox
Text
=
"{Binding Visible}"
/>
</
DataTemplate
>
</
telerik:PropertyDefinition.EditorTemplate
>
</
telerik:PropertyDefinition
>
</
telerik:RadPropertyGrid.PropertyDefinitions
>
</
telerik:RadPropertyGrid
>
</
DataTemplate
>
<
DataTemplate
DataType
=
"{x:Type PropertyGridTester:SecondClass}"
>
<
telerik:RadPropertyGrid
Item
=
"{Binding}"
AutoGeneratePropertyDefinitions
=
"False"
HorizontalAlignment
=
"Stretch"
SearchBoxVisibility
=
"Collapsed"
SortAndGroupButtonsVisibility
=
"Collapsed"
DescriptionPanelVisibility
=
"Collapsed"
HorizontalContentAlignment
=
"Stretch"
LabelColumnWidth
=
"110"
>
<
telerik:RadPropertyGrid.PropertyDefinitions
>
<
telerik:PropertyDefinition
Binding
=
"{Binding Visible}"
DisplayName
=
"Second class visible"
>
<
telerik:PropertyDefinition.EditorTemplate
>
<
DataTemplate
>
<
TextBox
Text
=
"{Binding Visible}"
/>
</
DataTemplate
>
</
telerik:PropertyDefinition.EditorTemplate
>
</
telerik:PropertyDefinition
>
</
telerik:RadPropertyGrid.PropertyDefinitions
>
</
telerik:RadPropertyGrid
>
</
DataTemplate
>
</
ContentControl.Resources
>
</
ContentControl
>
</
Grid
>
</
Window
>
using
System;
using
System.Windows.Input;
using
Microsoft.Practices.Prism.Commands;
using
Microsoft.Practices.Prism.ViewModel;
namespace
PropertyGridTester
{
public
abstract
class
BaseClass : NotificationObject
{
private
string
_Visible = String.Empty;
public
string
Visible
{
get
{
return
_Visible; }
set
{
if
(_Visible == value)
return
;
_Visible = value;
RaisePropertyChanged(() => Visible);
}
}
private
string
_NotVisible = String.Empty;
public
string
NotVisible
{
get
{
return
_NotVisible; }
set
{
if
(_NotVisible == value)
return
;
_NotVisible = value;
RaisePropertyChanged(() => NotVisible);
}
}
}
public
class
FirstClass : BaseClass
{
}
public
class
SecondClass : BaseClass
{
}
public
class
MainWindowViewModel : NotificationObject
{
public
MainWindowViewModel()
{
SetFirstClass =
new
DelegateCommand(() => SelectedClass =
new
FirstClass());
SetSecondClass =
new
DelegateCommand(() => SelectedClass =
new
SecondClass());
SetNull =
new
DelegateCommand(() => SelectedClass =
null
);
}
public
ICommand SetFirstClass {
get
;
private
set
; }
public
ICommand SetSecondClass {
get
;
private
set
; }
public
ICommand SetNull {
get
;
private
set
; }
private
BaseClass _SelectedClass =
null
;
public
BaseClass SelectedClass
{
get
{
return
_SelectedClass; }
set
{
if
(_SelectedClass == value)
return
;
_SelectedClass = value;
RaisePropertyChanged(() => SelectedClass);
}
}
}
}
<
Window
x:Class
=
"WpfApplication3.MainWindow"
xmlns:telerik
=
"http://schemas.telerik.com/2008/xaml/presentation"
xmlns:example
=
"clr-namespace:WpfApplication3"
Title
=
"MainWindow"
Height
=
"350"
Width
=
"525"
>
<
Window.DataContext
>
<
example:ExampleViewModel
/>
</
Window.DataContext
>
<
Grid
>
<
Popup
IsOpen
=
"True"
Width
=
"800"
Height
=
"300"
>
<
telerik:RadTimeline
Grid.Row
=
"0"
PeriodStart
=
"{Binding StartDate, Mode=TwoWay}"
PeriodEnd
=
"{Binding EndDate, Mode=TwoWay}"
VisiblePeriodStart
=
"{Binding VisibleStartDate, Mode=TwoWay}"
VisiblePeriodEnd
=
"{Binding VisibleEndDate, Mode=TwoWay}"
StartPath
=
"StartDate"
DurationPath
=
"Duration"
ToolTipPath
=
"Details"
ItemsSource
=
"{Binding Data}"
>
<
telerik:RadTimeline.Intervals
>
<
telerik:DayInterval
/>
<
telerik:YearInterval
IntervalSpans
=
"1,5"
/>
<
telerik:MonthInterval
IntervalSpans
=
"1,6"
/>
</
telerik:RadTimeline.Intervals
>
</
telerik:RadTimeline
>
</
Popup
>
</
Grid
>
</
Window
>
<
telerik:RadTileView
x:Name
=
"ListView1"
MaxRows
=
"1"
MaximizeMode
=
"Zero"
ScrollBarVisibility
=
"Visible"
ColumnWidth
=
"Auto"
Height
=
"210"
TileDragEnded
=
"RadTileView1_TileDragEnded"
ItemContainerStyle
=
"{DynamicResource RadTileViewItemStyle}"
HorizontalContentAlignment
=
"Left"
SelectionChanged
=
"ListView1_SelectionChanged"
IsItemDraggingEnabled
=
"True"
IsSelectionEnabled
=
"True"
IsAutoScrollingEnabled
=
"True"
>
<
telerik:RadTileView.ContentTemplate
>
<
DataTemplate
>
<
Grid
Margin
=
"10,0,10,0"
HorizontalAlignment
=
"Left"
>
<
Border
BorderThickness
=
"1"
Margin
=
"-2"
Background
=
"Transparent"
BorderBrush
=
"Black"
HorizontalAlignment
=
"Left"
VerticalAlignment
=
"Top"
>
<
Border.Effect
>
<
DropShadowEffect
ShadowDepth
=
"0"
BlurRadius
=
"10"
></
DropShadowEffect
>
</
Border.Effect
>
<
Image
Height
=
"Auto"
Width
=
"Auto"
VerticalAlignment
=
"Top"
Source
=
"{Binding ThumbnailImageControl}"
/>
</
Border
>
</
Grid
>
</
DataTemplate
>
</
telerik:RadTileView.ContentTemplate
>
</
telerik:RadTileView
>
<
Style
x:Key
=
"RadTileViewItemStyle"
TargetType
=
"{x:Type telerik:RadTileViewItem}"
>
<
Setter
Property
=
"Template"
>
<
Setter.Value
>
<
ControlTemplate
TargetType
=
"{x:Type telerik:RadTileViewItem}"
>
<
Border
x:Name
=
"GripBarElement"
Background
=
"Transparent"
Width
=
"Auto"
HorizontalAlignment
=
"Left"
VerticalAlignment
=
"Top"
>
<
Grid
Margin
=
"5"
HorizontalAlignment
=
"Left"
VerticalAlignment
=
"Top"
Width
=
"Auto"
>
<
Grid.RowDefinitions
>
<
RowDefinition
Height
=
"Auto"
/>
<
RowDefinition
Height
=
"*"
/>
</
Grid.RowDefinitions
>
<
ContentPresenter
x:Name
=
"ContentElement"
MouseDown
=
"img_MouseDown"
Grid.Row
=
"1"
Width
=
"Auto"
HorizontalAlignment
=
"Left"
VerticalAlignment
=
"Top"
Content
=
"{TemplateBinding Content}"
ContentTemplate
=
"{TemplateBinding ContentTemplate}"
/>
<
Grid
x:Name
=
"ContentCacheHost"
Grid.Row
=
"0"
Width
=
"Auto"
HorizontalAlignment
=
"Left"
VerticalAlignment
=
"Top"
/>
<
Grid
MinHeight
=
"23"
Grid.Row
=
"0"
>
<
Button
Content
=
"X"
Height
=
"23"
Margin
=
"0,0,0,0"
Width
=
"23"
Click
=
"btnDelete_Click"
Name
=
"btnDelete"
Tag
=
"{Binding FilePath}"
MouseEnter
=
"btnDelete_MouseEnter"
MouseLeave
=
"btnDelete_MouseLeave"
Foreground
=
"White"
FontSize
=
"14"
FontWeight
=
"Bold"
Opacity
=
".4"
VerticalAlignment
=
"Top"
HorizontalAlignment
=
"Left"
>
<
Button.Background
>
<
LinearGradientBrush
EndPoint
=
"0.5,1"
StartPoint
=
"0.5,0"
>
<
GradientStop
Color
=
"#00AF69"
Offset
=
"0"
/>
<
GradientStop
Color
=
"#138D5D"
Offset
=
"1"
/>
</
LinearGradientBrush
>
</
Button.Background
>
</
Button
>
</
Grid
>
</
Grid
>
</
Border
>
</
ControlTemplate
>
</
Setter.Value
>
</
Setter
>
</
Style
>
public ObservableCollection<
StaticObjects.BmpImage
> BitmapImageList { get; set; }
ListView1.ItemsSource = BitmapImageList;
if
(currentselectedindex > 0)
{
ListView1.SelectedIndex = currentselectedindex - 1;
ListView1.BringIntoView(ListView1.Items[currentselectedindex]);
}
void
btnDelete_Click(
object
sender, RoutedEventArgs e)
{
Button btn = (Button)sender;
string
filepath = btn.Tag.ToString();
StaticObjects.BmpImage bmp = BitmapImageList.Where(p => p.FilePath == btn.Tag).SingleOrDefault();
int
currentidex = ListView1.Items.IndexOf(bmp);
bmp.Dispose();
BitmapImageList.Remove(bmp);
}