Which assembly to reference for DataGrid?
I made my first WPF control:
<UserControl x:Class="Dealogic.VisualStudio.UI.DatabaseManage开发者_运维技巧r.Controls.TargetInstance"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Height="300" Width="300">
<Grid>
<DataGrid ItemsSource="{Binding Customers}" />
</Grid>
On the DataGrid control it says: "the type datagrid was not found, Verify that you are not missing an assembly refernece"
I'm creating the control within a Win Forms app. What assembly to I need to include and how do I do that in XAML?
thanks
Look up the control on msdn (I tend to google "msdn CONTROL_NAME"). On the page, it states the required assembly.
It depends on what version of WPF you are using. In older version the Datagrid came from WPFTOOLKIT that you need to install. In the new versions it's part of wpf.
microsoft.windows.controls
I've checked my code, here is a xaml for old datagrind:
<toolkit:DataGrid Margin="25,428,28,38" Grid.Column="2" ItemsSource="{Binding}" Name="grdEmails"></toolkit:DataGrid>
Here is one from VS2010:
<DataGrid AutoGenerateColumns="False" Height="200" HorizontalAlignment="Left" Margin="152,59,0,0" Name="dataGrid1" VerticalAlignment="Top" Width="200" />
It works with default ref.
The other answers are fine (Googling to find the assembly, then ensuring you have a reference to it). However, there is another important piece of information on the MSDN page, and that is the target framework. DataGrid is available in .NET 4.0 but not .NET 3.5, for instance.
精彩评论