c# - WPF, calling method with parameters in XAML's class -
I have a ObjectDataProvider
in my code that is a method in my window Gives context
-documented class. That is, I have referenced with NewForm.xaml.cs
class newform
and ObjectDataProvider
with newform.xaml One method in NewForm
. Currently, with the following XAML, I get a stack overflow error because the NewForm
constructor is repeatedly called:
& lt; Window x: orbit = "MyNamespace.NewForm" ... & gt; & Lt; Window.Resources & gt; & Lt; ObjectDataProvider x: key = "getTeamName" object type = "{x: type local: newForm}" methodname = "GetTeamName" & gt; & Lt; ObjectDataProvider.MethodParameters & gt; & Lt; Sys: Int32 & gt; -1 & lt; / Sys: Int32 & gt; & Lt; /ObjectDataProvider.MethodParameters> & Lt; / ObjectDataProvider & gt; & Lt; /Window.Resources> & Lt; / Window & gt;
I'm guessing this because object type
is set to NewForm
, so it's NewForm Loads, but then a new installation will be required to call
, but the manufacturer call NewForm
to GetTeamName InitializeComponent
Which is to create a new newform
for which to call a new newform
Anyway, what I am asking is, do I have to define ways that calls my XAML in another category through the ObjectDataProvider
? Or can I somehow use the ObjectDataProvider
with the method defined in my XAML class? Or to call a method in your XAML class, should I use some other XAML besides the ObjectDataProvider
? It does not seem that I can put my C # method in another category because it uses XmlDataProvider
to get TryingFindResource
from my XML.
The root of the problem here is that the ObjectDetTrawer Provider
is always the object created for it Makes a new example of So, this will create an example of the newform
class, whose constructor will start another ObjectDataProvider
which makes an example of the NewForm
class, and So this is completely turtle.
But the thing is that, ObjectDataProvider
is actually a way to declare objects and call methods in XAM, so that you do not have to back it up in the code since you first You are creating the code behind the code, so avoiding the code-behind you are not benefiting, so only the method that creates an object is also added to the window's resource dictionary:
/ / This method is now required to return anything Security is not, so your signature instead of personal zero change GetTeamName () {// code object makes it even gets // And now, "Return to Me object" in this resource. Add ("getTeamoname"); }
Comments
Post a Comment