Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8381755
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T16:45:58+00:00 2026-06-09T16:45:58+00:00

I’m crating a custom dialog class. It takes a list of OptionObject objects, in

  • 0

I’m crating a custom dialog class. It takes a list of OptionObject objects, in constructor. At some point it’s displayed and depending on which option the user clicks performs an action that is injected into OptionObject.

public class OptionObject
    {
        public object Id { get; set; }
        public string Text { get; set; }

        public Action Action { get; set; }

        public OptionObject(object id, string text, Action action)
        {
            this.Id = id;
            this.Text = text;
            this.Action = action;
        } 
}

This is how the actions are invoked by DialogWindow:

this.Options.Tap += (sender, args) =>   // Options is a ListBox
                                    {
                                        var o = sender as ListBox;
                                        var x = o.SelectedItem as OptionObject;
                                        if(x!=null)
                                            x.Action();
                                        this.IsOpen = false;
                                    };

And finally I’m trying to use my dialog on another page:

foreach (var o in eventsOnDate)
                {
                    chooseEventDialogWindow.Data.OptionsList.Add(new OptionObject(o.Text, ()=> /*### don't know what to put in here ###*/ ));
                }

The problem is that OptionObject.Action sometimes needs OptionObject.Id property. How can I access it in the sniped right above?

EDIT

I wouldn’t like to pass any parameters into this lambda expression if it’s possible, as sometime there’s no need for this Id. Optional parameters would be fine if this is the right way to go.

PS

This is not important for the question but to avoid unnecessary discussion this dialog is based on telerik’s RadWindow.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T16:45:59+00:00Added an answer on June 9, 2026 at 4:45 pm

    An Action is a method that has no parameters and does not return a value, so you either have to enclose your OptionObject.ID property when you create the Action delegate:

    object id = new object();
    Action act = () => DoSomethingWithIdAndReturnVoid(id);
    OptionObject opt = new OptionObject(id, "some text", act);
    opt.Action();
    

    Or do like Henk suggests in his comment, i.e., create an Action that has an input parameter:

    object id = new object();
    Action<object> act = (x) => DoSomethingWithIdAndReturnVoid(x);
    OptionObject opt = new OptionObject(id, "some text", act);
    opt.Action(opt.ID);
    

    Just be aware that changes to enclosed variables only work properly when dealing with Reference Types.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I used javascript for loading a picture on my website depending on which small
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am doing a simple coin flipping experiment for class that involves flipping a
I would like to run a str_replace or preg_replace which looks for certain words
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.