Repository navigation
How do I get a widget from xeto/xaml into C#? #3154
|
I have a <DropDown Name="DropMenu" />
Is something like this possible? Thanks in advance 👍 |
Replies: 2 comments 1 reply
|
Yep, you can do that. Use In <DropDown x:Name="DropMenu" />Then, inside your existing protected DropDown DropMenu { get; set; }
public MainForm()
{
XamlReader.Load(this);
DropMenu.Items.Add("Runtime added option");
}
Eto's own example does this with a named dropdown and a matching C# property. You can pass a string straight to |
|
Thanks for answering this @KevinAndrewDong. I've been working on improving .xeto/.jeto support recently, and with Eto 2.14 when released will be able to compile .xeto to code with |
Yep, you can do that. Use
x:Nameinstead ofName, then add a property with the same name in your code-behind.In
MainForm.xeto, change the dropdown to:Then, inside your existing
MainFormclass inMainForm.xeto.cs:XamlReader.Load(this)fills in the property, so theItems.Addline needs to come after it. The property name andx:Namehave to match exactly.Eto's own example does this with a named dropdown and a matching C# property. You can pass a string straight to
Items.Add, as in your original snippet.