C#WPF错误类型ComboLoad不支持直接内容

C#WPF错误类型ComboLoad不支持直接内容

问题描述:

你好朋友:)
我是C#和WPF的新手,但我一直陷在其中,但用Google搜索,但找不到答案.
请帮助:)

我的Qusetion,
我想在GetLoc中调用一个方法,该方法需要从我的xaml中获取1个参数(ComboLoad类的对象).

组合载荷等级

Hello Friends :)
I''m New to c# and wpf,and i''m stuck in this , i googled but i cant find a answer .
please Help :)

my Qusetion,
I want to call a Method in GetLoc that takes 1 argument (Object of ComboLoad Class) from my xaml.

Combo Load Class

namespace BE
{
    public class ComboLoad
    {
        public int MyProperty { get; set; }
    }
}



GetLoc类



GetLoc Class

namespace DS
{
    public class GetLoc
    {
        public GetLoc(ComboLoad obj)
        {

        }

        public void getCombodata(ComboLoad cmb)
        {
            new CmbLoad().getLocToCombo(cmb);


        }
    }
}



和我的XAML
/*<window.resources>
< ObjectDataProvider x:Key ="cmbObjectBE" ObjectType ="{x:Type BE:ComboLoad}"/>
< ObjectDataProvider ObjectType ="{x:Type DS:GetLoc}"
MethodName ="getCombodata" x:Key ="cmbObjectDS">
< ObjectDataProvider.MethodParameters>
< be:comboload xmlns:be =#unknown"> cmbObjectBE
</ObjectDataProvider.MethodParameters>
</ObjectDataProvider>


< grid datacontext ="{Binding Source = {StaticResource cmbObjectDS}}"> */

它说他们是这行的错误
< be:comboload xmlns:be ="#unknown> cmbObjectBE"

错误->类型ComboLoad不支持直接内容


对不起,英语不好
谢谢你! :)



And My XAML
/*<window.resources>
<ObjectDataProvider x:Key="cmbObjectBE" ObjectType="{x:Type BE:ComboLoad}" />
<ObjectDataProvider ObjectType="{x:Type DS:GetLoc}"
MethodName="getCombodata" x:Key="cmbObjectDS">
<ObjectDataProvider.MethodParameters>
<be:comboload xmlns:be="#unknown">cmbObjectBE
</ObjectDataProvider.MethodParameters>
</ObjectDataProvider>


<grid datacontext="{Binding Source={StaticResource cmbObjectDS}}">*/

It says their is a error in this line
"<be:comboload xmlns:be="#unknown">cmbObjectBE"

Error -> The Type ComboLoad Does Not Support direct Content


Sorry For the Poor English
And Thank You ! :)

是的,您的ObjectDataProvider.MethodParameters声明内不能有任何文本(cmbObjectBE).

http://msdn.microsoft.com/en-us/library/system.windows.data.objectdataprovider.methodparameters.aspx [ ^ ]

您需要指定参数值,例如:
Yes, your ObjectDataProvider.MethodParameters can not have any text (cmbObjectBE) inside the declaration.

http://msdn.microsoft.com/en-us/library/system.windows.data.objectdataprovider.methodparameters.aspx[^]

You need to specify the parameter value like:
<system:double xmlns:system="#unknown">0</system:double>


查看此链接,您可能会有所了解

http://*.com/questions/356663/how-do-i-resolve-the-wpf-designer-error-the-type-0-does-not-support-direct-co [ http://msdn.microsoft.com/en-us/library/bb514660%28v = vs.90%29.aspx [ ^ ]
see this links you may get some idea

http://*.com/questions/356663/how-do-i-resolve-the-wpf-designer-error-the-type-0-does-not-support-direct-co[^]

http://msdn.microsoft.com/en-us/library/bb514660%28v=vs.90%29.aspx[^]


-当您尝试使用不具有以下类型的对象元素语法时,会发生此错误ContentPropertyAttribute指定的内容属性.
-如果文件是格式正确的XAML文档,但包含一个或多个类型不匹配,则会引发此错误.


在此处查看详细信息: MSDN:类型"{0}"不支持直接内容 [ ^ ]
- This error occurs when you try to use object element syntax with a type which does not have a content property specified by the ContentPropertyAttribute.
- This error is raised when the file is a well-formed XAML document, but contains one or more type mismatches.


Look here for details: MSDN: The type ''{0}'' does not support direct content[^]