对象类型在WPF Datagrid中无法正常工作 [英] object Type is not working properly in WPF Datagrid

查看:65
本文介绍了对象类型在WPF Datagrid中无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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;
            }
        }       
    }    
}


<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>





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


如在键入"{x:Type local:}"/>时所讨论的那样,在此代码段中.智慧应该给出一个包含"CustomerDataProvider"的弹出窗口.但是就我而言,这不是我想要的,即我希望代码段像"{x:Type local:CustomerDataProvider}"一样.请帮助


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

推荐答案

没有遍历所有代码,但是如果问题仅仅是InelliSense没有提出任何建议,为什么不写正确的建议呢?手动输入.在许多情况下,Intellisense不会给出最新建议.
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.


这篇关于对象类型在WPF Datagrid中无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆