TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Kunal Kolambkar
NA
2
3.2k
My WPF Paging Custom Control Not Working
Jan 4 2014 1:14 PM
My WPF Paging Custom Control Not Working
I have created one custom control for paging data grid in WPF but it is not working. Please help me.
I am using my custom control as follows:
<Window x:Class="Frames.Masters.AreaWindow"
xmlns:uc="clr-namespace:Frames.UserControls">
...
<Grid.Resources>
<uc:PagedData x:Key="database" />
</Grid.Resources>
...
<xcdg:DataGridControl>
</xcdg:DataGridControl>
<uc:PagingControl x:Name="pager" Grid.Row="2" Height="25" ItemsSource="{Binding ocArea}"
PageContract="{StaticResource database}" />
I am using Xceed data grid above. Then declaring my custom control which is nothing but an user control which I have created which includes buttons and text boxes. I am assigning it to ObservableCollection which has 5 records.
My user control is PagingControl.xaml.
Its cs file is like, (I am giving partial code here)
public partial class PagingControl : UserControl
{
public static DependencyProperty ItemsSourceProperty;
public ObservableCollection<object> ItemsSource
{
get
{
return GetValue(ItemsSourceProperty) as ObservableCollection<object>;
}
set
{
SetValue(ItemsSourceProperty, value);
}
}
static PagingControl()
{
ItemsSourceProperty = DependencyProperty.Register("ItemsSource", typeof(ObservableCollection<object>), typeof(PagingControl), new PropertyMetadata(new ObservableCollection<object>()));
}
public IPageControlContract PageContract
{
get
{
return GetValue(PageContractProperty) as IPageControlContract;
}
set
{
SetValue(PageContractProperty, value);
}
}
private void SetDefaultValues()
{
PageContract.SetRecordSource(ItemsSource);
}
private void Navigate(PageChanges change)
{
uint TotalRecords;
short NewPageSize;
if (PageContract == null)
{
return;
}
TotalRecords = PageContract.GetTotalCount();
}
}
Here above IPageControlContract is an interface which is like below:
public interface IPageControlContract
{
void SetRecordSource(ObservableCollection<object> ocSource);
uint GetTotalCount();
ICollection<object> GetRecords(uint StartIndex, short NumberOfRecords);
}
Then I implement it as:
public class PagedData: IPageControlContract
{
ObservableCollection<object> oc;
public void SetRecordSource(ObservableCollection<object> ocSource)
{
oc = ocSource;
}
public uint GetTotalCount()
{
return (uint)oc.Count;
}
}
And this PagedData class is what I am referring in xaml via static resource. Now when I am debugging I am getting oc as null inside PagedData or oc having count zero even though my ocArea which is of type of some custom class 'Area' has 5 records. Now I have declared Observable Collection as type of object because I want my control to act on any type of object for paging.
Reply
Answers (
0
)
W P F DATE PICKER
WPF DatePicker Month Name Issue