导入wpf名称空间 [英] Importing wpf namespaces
问题描述
我想在xaml标记中引用一类枚举。我已经通过在项目的References部分使用Add User Import成功引用了这个类。我现在可以从VB端访问这些枚举,但不能从XAML访问。
I want to reference a class of enumerations in the xaml markup. I have successfully referenced this class by using "Add User Import" on the References section of my project. I can now access these enumerations from the VB side, but not from XAML.
<Window x:Class="Window2"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
xmlns:gcl="clr-namespace:GeomaniacClassLibrary.Enumerations;assembly=GeomaniacClassLibrary"
智能sense不允许我访问.Enumerations类。以下代码给出错误说错误7命名空间PointClass在命名空间clr-namespace:GeomaniacClassLibrary.Enumerations; assembly = GeomaniacClassLibrary中不存在。
The intellisense does not allow me to access the .Enumerations class. The following code gives an error saying Error 7 The name "PointClass" does not exist in the namespace "clr-namespace:GeomaniacClassLibrary.Enumerations;assembly=GeomaniacClassLibrary".
<Window.Resources>
<ObjectDataProvider MethodName="GetValues"
ObjectType="{x:Type sys:Enum}"
x:Key="PointClasses">
<ObjectDataProvider.MethodParameters>
<x:Type TypeName="gcl:PointClass" />
</ObjectDataProvider.MethodParameters>
</ObjectDataProvider>
</Window.Resources>
有什么想法吗?
Any ideas ?
推荐答案
我似乎已经自己解决了这个问题。
我在GeomaniacClassLibrary中创建了一个Enumerations命名空间并添加了我的枚举它。它现在出现在xaml intellisense中并起作用。
I appear to have solved the problem myself.
I created an Enumerations namespace in GeomaniacClassLibrary and added my enumerations to it. It now appears in the xaml intellisense and works.
这篇关于导入wpf名称空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!