Hey guys,
I've got a problem which is really frustrating. I am trying to display content based on its type in a RadGridView. Therefore I am using a DataTemplate referenced to a DataType. Sadly it seems like the DataType isnt beeing recognized at all. If I change the DataMemberBinding from "{Binding}" to a member of the object which is of type string - it is working but thats not what I need, i need it to be working with my own Data types(classes).
Code:
XAML
CS:
I've got a problem which is really frustrating. I am trying to display content based on its type in a RadGridView. Therefore I am using a DataTemplate referenced to a DataType. Sadly it seems like the DataType isnt beeing recognized at all. If I change the DataMemberBinding from "{Binding}" to a member of the object which is of type string - it is working but thats not what I need, i need it to be working with my own Data types(classes).
Code:
XAML
<Window x:Class="RadControlsWpfApp1.MainWindow" xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation" xmlns:local="clr-namespace:RadControlsWpfApp1" xmlns:System="clr-namespace:System;assembly=mscorlib" Title="MainWindow" Height="350" Width="525"> <Grid> <telerik:RadGridView x:Name="Grid" Grid.Column="1" Margin="11,10,9,50" Grid.Row="1" ItemsSource="{Binding}" > <telerik:RadGridView.Columns> <telerik:GridViewDataColumn IsReadOnly="True" Header="test" DataMemberBinding="{Binding}" > <telerik:GridViewDataColumn.Resources> <DataTemplate DataType="{x:Type local:Foo}"> <TextBlock Text="test" /> </DataTemplate> </telerik:GridViewDataColumn.Resources> </telerik:GridViewDataColumn> </telerik:RadGridView.Columns> </telerik:RadGridView> </Grid></Window>CS:
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;namespace RadControlsWpfApp1{ public class Foo { public string Name { get; set; } public string Value { get; set; } } public class Foo2 { public string Name { get; set; } public string Value { get; set; } } /// <summary> /// Interaction logic for MainWindow.xaml /// </summary> /// public partial class MainWindow : Window { public MainWindow() { var list = new List<object> { new Foo2() { Name = "Brian2", Value = "val2" }, new Foo() { Name = "Brian", Value = "val1" } }; InitializeComponent(); Grid.DataContext = list; } }}