This is a migrated thread and some comments may be shown as answers.

WPF and bindingnavigator

5 Answers 121 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Kwabena
Top achievements
Rank 1
Kwabena asked on 26 Jul 2010, 05:32 AM
I downloaded a project from Telerik named WPFBindingNavigator to get bindingnavigator into my WPF project.  The downloaded project works when run, but the designer throws an "object reference not set to an instance of the object" error.  I am trying to replicate the functionality within my WPF application but cannot seem to get past this error during design time.

Following is a snippet of the error in the "Presentation" project (which references the WPFBindingNavigator, which is a class library):
 
xmlns:bn="clr-namespace:BindingNavigator;assembly=BindingNavigator"
The next code block raises the error mentioned above:
<bn:BindingNavigator Grid.Row="0" Margin="2" 
Background="Wheat"
x:Name="navigator"
ItemsSource="{Binding People}"
AddNewItemCommand="{Binding AddNewPersonCommand}"
DeleteItemCommand="{Binding DeletePersonCommand}"
SaveCommand="{Binding SaveCommand}"
/>

Any help will be appreciated.  Also, if there is a better way of creating the BindingNavigation functionality within WPF, please let me know.

Thanks in advance.

5 Answers, 1 is accepted

Sort by
0
Accepted
Yavor Georgiev
Telerik team
answered on 26 Jul 2010, 09:20 AM
Hello Kwabena,

 You need to find the IsCollection method in BindingNavigator.cs and change it to this:

private static bool IsCollection(IEnumerable obj)
{
    if (obj == null)
    {
        return false;
    }
    return GetEnumerableGenericArgument(obj.GetType()) != null
           && obj is IList;
}

Sincerely yours,
Yavor Georgiev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Kwabena
Top achievements
Rank 1
answered on 27 Jul 2010, 04:15 AM

Thank you very much Yavor.  That fixed the problem.

I do have a follow-up question.  Could you please tell me how to configure/program the BindingNavigator to use a different datasource?  I used ORM Reverse Mapping to model my database and will like to use that for my bindingnavigator.

Thanks again.

0
Yavor Georgiev
Telerik team
answered on 27 Jul 2010, 08:49 AM
Hi Kwabena,

 Generally, everything of type IEnumerable<> should work for just browsing, and IList<> for adding/deleting. You'll need to tell me more about your ORM solution so that I can help you on that.

All the best,
Yavor Georgiev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Kwabena
Top achievements
Rank 1
answered on 02 Aug 2010, 06:27 AM
I am definetely missing some obvious holes but well, I'm a newbie...And I need some help to get past this stage with the bindingnavigator and crud operations on openaccess.

I have my form which uses {Binding...} to "call" commands.  I have code for the commands in my viewmodel class e.g.
    public ICommand AddNewAssetCategory
    {
        get;
        private set;
    }
Also in the viewmodel class, I have the following:
        private void AddNewAssetCategory(object parameter)
        {
            AssetCat.Add(new AssetCategory());
        }
and
        private void Save(object parameter)
        {
            var assetCategory = parameter as AssetCategory;
            if (assetCategory != null)
            {
                this.AssetCat.Add(assetCategory);
            }
        }
In stepping through my code, it looks like the "parameter" object in Save(object parameter) is always null.

Please let me know what I'm missing.

Thanks for all your help so far.
0
Ladislav
Top achievements
Rank 1
answered on 08 Feb 2012, 11:48 PM
Hello Kwabena,

I know it is some time lost, but I would like to ask You if do You have still the project from Telerik named WPFBindingNavigator?

I am looking for that tool? And I canĀ“t find nothing usefull.

Thank You very much.
Tags
General Discussions
Asked by
Kwabena
Top achievements
Rank 1
Answers by
Yavor Georgiev
Telerik team
Kwabena
Top achievements
Rank 1
Ladislav
Top achievements
Rank 1
Share this question
or