This question is locked. New answers and comments are not allowed.
When i try to use datapager with the datagrid, the grid is not selectable... I dont know wats wrong.
<UserControl x:Class="crmRequests.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:data="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data"
xmlns:telerikNavigation ="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Navigation"
xmlns:grid="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.GridView"
xmlns:gridview="clr-namespace:Telerik.Windows.Controls.GridView;assembly=Telerik.Windows.Controls.GridView"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="600">
<Grid x:Name="LayoutRoot">
<telerikNavigation:RadTabControl FontSize="15" x:Name="tabControl" Margin="20" BorderThickness="1" Align="Justify" >
<telerikNavigation:RadTabItem Header="Home" Name="tabHome">
</telerikNavigation:RadTabItem>
<telerikNavigation:RadTabItem Header="Account Info">
</telerikNavigation:RadTabItem>
<telerikNavigation:RadTabItem Header="Knowledge Base">
</telerikNavigation:RadTabItem>
<telerikNavigation:RadTabItem Header="New Request">
</telerikNavigation:RadTabItem>
<telerikNavigation:RadTabItem Header="Open Requests" Name="tabOpenREquest">
<Grid>
<grid:RadGridView x:Name="gdOpenRequests" AutoGenerateColumns="False" ShowColumnFooters="True" IsReadOnly="True"></grid:RadGridView>
<data:DataPager x:Name="customerPager" Grid.Row="1" PageSize="100" Source="{Binding Path=ItemsSource,ElementName=gdOpenRequests}"></data:DataPager>
</Grid>
</telerikNavigation:RadTabItem>
<telerikNavigation:RadTabItem Header="Request History">
<Grid>
<grid:RadGridView x:Name="gdRequestHistory" ShowGroupFooters="True" AutoGenerateColumns="False" IsReadOnly="True"></grid:RadGridView>
</Grid>
</telerikNavigation:RadTabItem>
<telerikNavigation:RadTabItem Header="Audit My Workstation"/>
</telerikNavigation:RadTabControl>
</Grid>
</UserControl>
CodeBehind::
Imports System.Linq
Imports System.Xml
Imports System.Windows.Data
Imports System.Xml.Linq
Imports System.Collections
Imports System.Collections.Generic
Imports System.Collections.ObjectModel
Imports Telerik.Windows
Imports Telerik.Windows.Controls
Imports Telerik.Windows.Controls.GridView
Imports crmRequests.TestSrv
Partial Public Class MainPage
Inherits UserControl
Dim objTestSrv As TestSrv.TestServiceClient = Nothing
Private customers As ObservableCollection(Of clsCustomer)
Public Sub New()
InitializeComponent()
gdOpenRequests.[AddHandler](GridViewCell.MouseDoubleClickEvent, _
New EventHandler(Of RadRoutedEventArgs)(AddressOf Me.OnDoubleClickCellaGrigliaListino))
End Sub
Public Sub OnDoubleClickCellaGrigliaListino(ByVal sender As Object, ByVal e As RadRoutedEventArgs)
If Not IsNothing(e.Source) Then
Dim SelectedRow As GridViewRow = CType(e.Source, GridViewCell).ParentRow
MessageBox.Show("Name = " & SelectedRow.Cells(0).Content)
End If
End Sub
Private Sub MainPage_Loaded(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles Me.Loaded
initGrid()
objTestSrv = New TestSrv.TestServiceClient()
objTestSrv.GetDataAsync()
AddHandler objTestSrv.GetDataCompleted, AddressOf objTestSrv_GetDataCompleted
End Sub
Private Sub initGrid()
gdOpenRequests.AutoGenerateColumns = False
gdOpenRequests.HorizontalAlignment = HorizontalAlignment.Center
gdOpenRequests.ColumnsWidthMode = ColumnsWidthMode.Fill
gdOpenRequests.ShowGroupPanel = False
gdOpenRequests.UseAlternateRowStyle = True
AddGridColumn("Name", "ContactName")
AddGridColumn("ID", "CustomerID")
AddGridColumn("EmailId", "ContactTitle")
AddGridColumn("Location", "CompanyName")
End Sub
Private Sub AddGridColumn(ByVal Name As String, ByVal UniquieName As String)
Dim Col As New GridViewDataColumn()
Col.Header = Name
Col.UniqueName = UniquieName
gdOpenRequests.Columns.Add(Col)
End Sub
Private Sub objTestSrv_GetDataCompleted(ByVal sender As Object, ByVal e As TestSrv.GetDataCompletedEventArgs)
If IsNothing(e.Error) Then
Dim obj() As crmRequests.TestSrv.stcCustomers
For Each aj As crmRequests.TestSrv.stcCustomers In e.Result
If IsNothing(obj) OrElse obj.Length = 0 Then
ReDim Preserve obj(0)
Else
ReDim Preserve obj(obj.Length)
End If
obj(obj.Length - 1) = aj
Next
Dim pgView As PagedCollectionView = New PagedCollectionView(e.Result)
' customerPager.Source = New PagedCollectionView(e.Result)
gdOpenRequests.ItemsSource = New PagedCollectionView(e.Result)
End If
End Sub
Protected Function GetCustomersFromDocument(ByVal document As XDocument) As ObservableCollection(Of clsCustomer)
Dim list As New ObservableCollection(Of clsCustomer)()
For Each element As XElement In document.Descendants("Customers")
Dim customer As New clsCustomer()
customer.CustomerID = element.Element("CustomerID").Value
customer.CompanyName = element.Element("CompanyName").Value
customer.Country = element.Element("Country").Value
customer.City = element.Element("City").Value
customer.ContactName = element.Element("ContactName").Value
customer.ContactTitle = element.Element("ContactTitle").Value
customer.Address = element.Element("Address").Value
customer.PostalCode = If(element.Element("PostalCode") IsNot Nothing, element.Element("PostalCode").Value, Nothing)
customer.Phone = element.Element("Phone").Value
customer.Fax = If(element.Element("Fax") IsNot Nothing, element.Element("Fax").Value, Nothing)
customer.Bool = CBool(element.Element("Bool"))
list.Add(customer)
Next
Return list
End Function
End Class
<UserControl x:Class="crmRequests.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:data="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data"
xmlns:telerikNavigation ="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Navigation"
xmlns:grid="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.GridView"
xmlns:gridview="clr-namespace:Telerik.Windows.Controls.GridView;assembly=Telerik.Windows.Controls.GridView"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="600">
<Grid x:Name="LayoutRoot">
<telerikNavigation:RadTabControl FontSize="15" x:Name="tabControl" Margin="20" BorderThickness="1" Align="Justify" >
<telerikNavigation:RadTabItem Header="Home" Name="tabHome">
</telerikNavigation:RadTabItem>
<telerikNavigation:RadTabItem Header="Account Info">
</telerikNavigation:RadTabItem>
<telerikNavigation:RadTabItem Header="Knowledge Base">
</telerikNavigation:RadTabItem>
<telerikNavigation:RadTabItem Header="New Request">
</telerikNavigation:RadTabItem>
<telerikNavigation:RadTabItem Header="Open Requests" Name="tabOpenREquest">
<Grid>
<grid:RadGridView x:Name="gdOpenRequests" AutoGenerateColumns="False" ShowColumnFooters="True" IsReadOnly="True"></grid:RadGridView>
<data:DataPager x:Name="customerPager" Grid.Row="1" PageSize="100" Source="{Binding Path=ItemsSource,ElementName=gdOpenRequests}"></data:DataPager>
</Grid>
</telerikNavigation:RadTabItem>
<telerikNavigation:RadTabItem Header="Request History">
<Grid>
<grid:RadGridView x:Name="gdRequestHistory" ShowGroupFooters="True" AutoGenerateColumns="False" IsReadOnly="True"></grid:RadGridView>
</Grid>
</telerikNavigation:RadTabItem>
<telerikNavigation:RadTabItem Header="Audit My Workstation"/>
</telerikNavigation:RadTabControl>
</Grid>
</UserControl>
CodeBehind::
Imports System.Linq
Imports System.Xml
Imports System.Windows.Data
Imports System.Xml.Linq
Imports System.Collections
Imports System.Collections.Generic
Imports System.Collections.ObjectModel
Imports Telerik.Windows
Imports Telerik.Windows.Controls
Imports Telerik.Windows.Controls.GridView
Imports crmRequests.TestSrv
Partial Public Class MainPage
Inherits UserControl
Dim objTestSrv As TestSrv.TestServiceClient = Nothing
Private customers As ObservableCollection(Of clsCustomer)
Public Sub New()
InitializeComponent()
gdOpenRequests.[AddHandler](GridViewCell.MouseDoubleClickEvent, _
New EventHandler(Of RadRoutedEventArgs)(AddressOf Me.OnDoubleClickCellaGrigliaListino))
End Sub
Public Sub OnDoubleClickCellaGrigliaListino(ByVal sender As Object, ByVal e As RadRoutedEventArgs)
If Not IsNothing(e.Source) Then
Dim SelectedRow As GridViewRow = CType(e.Source, GridViewCell).ParentRow
MessageBox.Show("Name = " & SelectedRow.Cells(0).Content)
End If
End Sub
Private Sub MainPage_Loaded(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles Me.Loaded
initGrid()
objTestSrv = New TestSrv.TestServiceClient()
objTestSrv.GetDataAsync()
AddHandler objTestSrv.GetDataCompleted, AddressOf objTestSrv_GetDataCompleted
End Sub
Private Sub initGrid()
gdOpenRequests.AutoGenerateColumns = False
gdOpenRequests.HorizontalAlignment = HorizontalAlignment.Center
gdOpenRequests.ColumnsWidthMode = ColumnsWidthMode.Fill
gdOpenRequests.ShowGroupPanel = False
gdOpenRequests.UseAlternateRowStyle = True
AddGridColumn("Name", "ContactName")
AddGridColumn("ID", "CustomerID")
AddGridColumn("EmailId", "ContactTitle")
AddGridColumn("Location", "CompanyName")
End Sub
Private Sub AddGridColumn(ByVal Name As String, ByVal UniquieName As String)
Dim Col As New GridViewDataColumn()
Col.Header = Name
Col.UniqueName = UniquieName
gdOpenRequests.Columns.Add(Col)
End Sub
Private Sub objTestSrv_GetDataCompleted(ByVal sender As Object, ByVal e As TestSrv.GetDataCompletedEventArgs)
If IsNothing(e.Error) Then
Dim obj() As crmRequests.TestSrv.stcCustomers
For Each aj As crmRequests.TestSrv.stcCustomers In e.Result
If IsNothing(obj) OrElse obj.Length = 0 Then
ReDim Preserve obj(0)
Else
ReDim Preserve obj(obj.Length)
End If
obj(obj.Length - 1) = aj
Next
Dim pgView As PagedCollectionView = New PagedCollectionView(e.Result)
' customerPager.Source = New PagedCollectionView(e.Result)
gdOpenRequests.ItemsSource = New PagedCollectionView(e.Result)
End If
End Sub
Protected Function GetCustomersFromDocument(ByVal document As XDocument) As ObservableCollection(Of clsCustomer)
Dim list As New ObservableCollection(Of clsCustomer)()
For Each element As XElement In document.Descendants("Customers")
Dim customer As New clsCustomer()
customer.CustomerID = element.Element("CustomerID").Value
customer.CompanyName = element.Element("CompanyName").Value
customer.Country = element.Element("Country").Value
customer.City = element.Element("City").Value
customer.ContactName = element.Element("ContactName").Value
customer.ContactTitle = element.Element("ContactTitle").Value
customer.Address = element.Element("Address").Value
customer.PostalCode = If(element.Element("PostalCode") IsNot Nothing, element.Element("PostalCode").Value, Nothing)
customer.Phone = element.Element("Phone").Value
customer.Fax = If(element.Element("Fax") IsNot Nothing, element.Element("Fax").Value, Nothing)
customer.Bool = CBool(element.Element("Bool"))
list.Add(customer)
Next
Return list
End Function
End Class
