Hi,
I am try to bind a RadGridView to DataView because of the Notify events that are already available. I am using the WPF MVVM architecture therefore the Grid is defined in the XAML and the DataView in my presentation Layer. I have a background worker that will populate the table in the DataView and I was hoping the RadGridView would then update accordingly. I am not too sure why it is not working or whether it can work in this context. Please see the code snippet below.
View:
<telerikGrid:RadGridView x:Name="activeSessionsGrid" AutoGenerateColumns="True" ItemsSource="{Binding Path=ActiveSessions}"
</telerikGrid:RadGridView>
Presentation Model:
private DataView _activeSessions;
public DataView ActiveSessions
{
get
{
return this._activeSessions;
}
}
private void GenereateTableStructure ( )
{
this._activeSessions = new DataView ( );
this._activeSessions.Table = new DataTable ( "Sessions" );
this._activeSessions.Table.Columns.Add ( "ID" );
this._activeSessions.Table.Columns.Add ( "Name" );
this._activeSessions.Table.Columns.Add ( "Surname" );
this._activeSessions.Table.Columns.Add ( "Designation" );
this._activeSessions.Table.Columns.Add ( "User Name" );
this._activeSessions.Table.Columns.Add ( "Email Address" );
this._activeSessions.Table.Columns.Add ( "Last Access Time" );
}
//BackgroundWorker that populates the _activeSessions table
Thanks in advance for your assistance.
I want to localize my GridView from xml file which has translation for my GridView headers.
I use next code:
<Window.Resources> <Style TargetType="telerik:GridViewDataColumn"> <Setter Property="Header" Value="someValue"/> </Style> </Window.Resources> <Grid> <telerik:RadGridView HorizontalAlignment="Left" Name="radGridView1" VerticalAlignment="Top" > </telerik:RadGridView> </Grid>
public partial class Window1 : Window{ public Window1() { InitializeComponent(); var lst = new List<Foo> { new Foo() {CompanyName = "Burkinafaso", Phone = "6666"}, new Foo() {CompanyName = "Reebok", Phone = "555"} }; radGridView1.SetBinding(RadGridView.ItemsSourceProperty, new Binding {Source = lst}); }}public class Foo{ public string CompanyName { get; set; } public string Phone { get; set; }}