Click here to Skip to main content
15,881,424 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
C#
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.Data;
using System.Data.OleDb;
using WPF9112.NorthwindDataSetTableAdapters;
using System.Windows.Shapes;

namespace WPF9112
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class DatasetCRUDExample : Window
    {
       
        public class CustomerDataProvider
        {
            private CustomersTableAdapter adapter;

            private NorthwindDataSet dataset;

            public CustomerDataProvider()
            {
                dataset = new NorthwindDataSet();
                adapter = new CustomersTableAdapter();
                adapter.Fill(dataset.Customers);
            }

            public DataView GetCustomers()
            {
                return dataset.Customers.DefaultView;
            }
        }       
    }    
}

HTML
<Window x:Class="WPF9112.DatasetCRUDExample"
        
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="clr-namespace:WPF9112"
         xmlns:dg="http://schemas.microsoft.com/wpf/2008/toolkit"
        Title="MyWindow" Height="900" Width="1200" WindowState="Maximized"
        WindowStyle="ThreeDBorderWindow" removed="Black" BorderBrush="Red" 
        Foreground="White" FontSize="30" FontWeight="Bold"
        AllowsTransparency="False" AllowDrop="True" IsManipulationEnabled="True"
        UseLayoutRounding="True" xmlns:my="clr-namespace:System;assembly=mscorlib">
    <Window.Resources>
        <!-- create an instance of our DataProvider class -->
        <ObjectDataProvider x:Key="CustomerDataProvider" ObjectType="{x:Type local:}" />
            
        <!-- define the method which is invoked to obtain our data -->
        <ObjectDataProvider x:Key="Customers"
          ObjectInstance="{StaticResource CustomerDataProvider}"
          MethodName="GetCustomers"/>
        <my:Boolean x:Key="CanUserAddRows1">True</my:Boolean>
        <my:Boolean x:Key="CanUserDeleteRows1">True</my:Boolean>
    </Window.Resources>
    
    <Grid Width="1200" Height="900" Name="Mygrid" removed="Black">
        
        <Grid.RowDefinitions>
            <RowDefinition Height="40*" />
            <RowDefinition Height="40*" />

        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            
            <ColumnDefinition Width="40*" />
            <ColumnDefinition Width="40*" />
            <ColumnDefinition Width="40*" />

        </Grid.ColumnDefinitions>
        <Border BorderBrush="Red" BorderThickness="1" Grid.ColumnSpan="29" Grid.RowSpan="28" Height="762" 
                HorizontalAlignment="Left" Name="myBorder" VerticalAlignment="Top" Width="1188">
            <dg:DataGrid ItemsSource="{Binding}" AutoGenerateColumns="True" Height="761" Name="mygrid" Width="1186" HorizontalGridLinesBrush="Red"
                      VerticalGridLinesBrush="Red" AlternatingRowBackground="Azure"
                      AlternationCount="1" RowBackground="Cornsilk" removed="WhiteSmoke" FontSize="20" HorizontalScrollBarVisibility="Visible" 
                         MinRowHeight="10"  BorderBrush="Red" 
                         VerticalScrollBarVisibility="Visible"  
                         RowDetailsVisibilityMode="Visible" IsManipulationEnabled="True" FrozenColumnCount="1"></dg:DataGrid>
        </Border>
        <Button Grid.Column="3" Grid.ColumnSpan="3" Grid.Row="28" Grid.RowSpan="2"
                Height="41" HorizontalAlignment="Left" Name="btnOpen" 
                VerticalAlignment="Top" Width="85" Content="Open" Background="Green" />
    </Grid>
</Window>


HTML
<ObjectDataProvider x:Key="CustomerDataProvider" ObjectType="{x:Type local:}" />

in this code segment as discussed while typing this "{x:Type local:}" /> the intellisence should give a popup window which contain "CustomerDataProvider". but it is not coming in my case ie I want the code segment to be just like "{x:Type local:CustomerDataProvider}". Please help
Posted
Updated 8-Jan-12 4:41am
v2

1 solution

Didn't go through all the code but if the problem is simply that the InelliSense isn't making any suggestions, why not write the proper type by hand. There are several cases when Intellisense doesn't give up-to-date suggestions.
 
Share this answer
 
Comments
[no name] 8-Jan-12 10:49am    
I meant to say while writing the code as explained it is giving error. but the same code segment is written in a blog
Wendelius 8-Jan-12 10:53am    
What error are you getting?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900