or
System.TypeInitializationException was unhandled<br>Message: Se produjo una excepción en el inicializador de tipo de
'Telerik.Windows.Documents.UI.Extensibility.RadCompositionInitializer'.
// Dependency Property
public static readonly DependencyProperty StringFormatProperty =
DependencyProperty.Register("StringFormat", typeof(string),
typeof(GridViewDateTimeColumn), new FrameworkPropertyMetadata(string.Empty, StringFormatChanged));
public string StringFormat
{
get { return (string)GetValue(StringFormatProperty); }
set { SetValue(StringFormatProperty, value); }
}
private static void StringFormatChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var column = (GridViewDateTimeColumn)d;
column.DataMemberBinding.StringFormat = e.NewValue.ToString();
column.Refresh();
}
<
my_controls:GridViewDateTimeColumn
DataMemberBinding
=
"{Binding SomeDateTimeProperty, Mode=TwoWay}"
StringFormat
=
"{Binding DataContext.StringFormat, RelativeSource={RelativeSource AncestorType=UserControl}}"
>
<
telerik:RadTreeListView.ItemsSource
><
br
>
<
MultiBinding
Converter
=
"{StaticResource IsExpandedToCollectionViewConverter}"
>
<
Binding
Path
=
"IsExpanded"
/>
<
Binding
Path
=
"DataContext"
RelativeSource
=
"{RelativeSource AncestorType=Grid}"
/>
</
MultiBinding
>
</
telerik:RadTreeListView.ItemsSource
>
RadDragAndDropManager.SetAllowDrop(mapAreaItemsControl , true);
RadDragAndDropManager.AddDropQueryHandler(mapAreaItemsControl, new EventHandler<DragDropQueryEventArgs>( OnDropQuery ) ); RadDragAndDropManager.AddDropInfoHandler(mapAreaItemsControl, new EventHandler<DragDropEventArgs>( OnDropInfo ) );
private void OnDropQuery( object sender, DragDropQueryEventArgs e ) { e.QueryResult = true; e.Handled = true; }
public
object
Convert(
object
value, Type targetType,
object
parameter, CultureInfo culture)
{
var item = value
as
Structure;
var items = value
as
SturctureCollection;
if
(items !=
null
)
{
return
items.Where(i => i.ParentID == 0);
}
else
if
(item !=
null
)
{
var parent = (item.Parent
as
StructureCollection);
return
parent.Where(i => i.ParentID == item.ID);
}
return
null
;
}
<
Style
TargetType
=
"{x:Type telerik:RadListBoxItem}"
>
<
Style.Triggers
>
<
Trigger
Property
=
"IsKeyboardFocusWithin"
Value
=
"True"
>
<
Setter
Property
=
"IsSelected"
Value
=
"True"
/>
</
Trigger
>
</
Style.Triggers
>
</
Style
>
<
Window
x:Class
=
"IsKeyboardFocusWithin.MainWindow"
xmlns:telerik
=
"http://schemas.telerik.com/2008/xaml/presentation"
Title
=
"MainWindow"
Height
=
"350"
Width
=
"525"
>
<
Window.Resources
>
<
DataTemplate
x:Key
=
"ListBoxItemTemplate"
>
<
TextBox
Text
=
"aasdf asdf asdf asdf asf "
/>
</
DataTemplate
>
<
Style
TargetType
=
"{x:Type ListBoxItem}"
>
<
Style.Triggers
>
<
Trigger
Property
=
"IsKeyboardFocusWithin"
Value
=
"True"
>
<
Setter
Property
=
"IsSelected"
Value
=
"True"
/>
</
Trigger
>
</
Style.Triggers
>
</
Style
>
<
Style
TargetType
=
"{x:Type telerik:RadListBoxItem}"
>
<
Style.Triggers
>
<
Trigger
Property
=
"IsKeyboardFocusWithin"
Value
=
"True"
>
<
Setter
Property
=
"IsSelected"
Value
=
"True"
/>
</
Trigger
>
</
Style.Triggers
>
</
Style
>
</
Window.Resources
>
<
Grid
>
<
Grid.RowDefinitions
>
<
RowDefinition
/>
<
RowDefinition
/>
</
Grid.RowDefinitions
>
<
ListBox
x:Name
=
"lstList"
ItemTemplate
=
"{StaticResource ListBoxItemTemplate}"
VerticalContentAlignment
=
"Stretch"
ItemsSource
=
"{Binding}"
SelectionMode
=
"Single"
/>
<
telerik:RadListBox
x:Name
=
"lstTelerikList"
ItemTemplate
=
"{StaticResource ListBoxItemTemplate}"
VerticalContentAlignment
=
"Stretch"
ItemsSource
=
"{Binding}"
SelectionMode
=
"Single"
Grid.Row
=
"1"
/>
</
Grid
>
</
Window
>
public
partial
class
MainWindow : Window
{
public
MainWindow()
{
Items =
new
ObservableCollection<
string
>() {
"Item 1"
,
"Item 2"
,
"Item 3"
};
InitializeComponent();
lstList.DataContext = Items;
lstTelerikList.DataContext = Items;
}
public
ObservableCollection<
string
> Items
{
get
;
set
;
}
}