Skip to content
Discussion options

You must be logged in to vote

Yep, you can do that. Use x:Name instead of Name, then add a property with the same name in your code-behind.

In MainForm.xeto, change the dropdown to:

<DropDown x:Name="DropMenu" />

Then, inside your existing MainForm class in MainForm.xeto.cs:

protected DropDown DropMenu { get; set; }

public MainForm()
{
    XamlReader.Load(this);
    DropMenu.Items.Add("Runtime added option");
}

XamlReader.Load(this) fills in the property, so the Items.Add line needs to come after it. The property name and x:Name have 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.

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@Antonio225t
Comment options

Answer selected by Antonio225t
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants