XamlParseException in view

I have a view that only shows a label.

The view mode is correctly entered in the view because the label text is bound to the viewmodel property. Now, if I try to define a DataGrid in xaml, I have a XamlParseException:

{System.Windows.Markup.XamlParseException: Type "DataGrid" not found. [Line: 16 Position: 45] su System.Windows.Application.LoadComponent (component of an object, Uri resourceLocator) su Common.Views.FunctionalityView.InitializeComponent () su Common.Views.FunctionalityView..ctor (display mode of functionality MMM)}

BUT, if I define a DataGrid myDg = new DataGrid()immediately before InitializeComponent();, it works.

I checked all the links and still can not find the problem.

0
source share
1 answer

It looks like your default namespace is confused or missing. Without haml it's hard to say what you should do.

An easy way to understand this for yourself is to create a new UserControl and then examine and compare the xmlns namespaces defined in its root with the root element of your view.

WPF finds types using a specialized namespace definition. It follows the format

clr-namespace: [namespace] (; assembly = [assembly name])

Where

[names]

- , . , , xaml, . [assembly name] - .dll(, assembly=mscorlib mscorlib.dll). Int32- xaml,

xmlns:s="clr-namespace:System;assembly=mscorlib"

, . , URL-. , , IIRC. ,

XMLNS = "http://schemas.microsoft.com/winfx/2006/xaml/presentation"

+1

All Articles