Skip to content

what is IsMarked? #2321

Answered by tznind
RetroGaming12221 asked this question in Q&A
Feb 6, 2023 · 1 comments · 5 replies
Discussion options

You must be logged in to vote

It indicates whether user has ticked the item when AllowsMarking is true on a ListView. If you are writing your own custom IListDataSource and you are not ever using any instances that have ticking enabled then you can ignore it.


Space toggles IsMarked while Enter completes selection (see code below)

using Terminal.Gui;

Application.Init();

var w = new Window();
var lv = new ListView(new List<string> { "fish", "cat" })
{
    Width = 10,
    Height = 5,
    AllowsMarking = true
};

w.Add(lv);

lv.KeyPress += k =>
{
    if (k.KeyEvent.Key == Key.Enter)
    {
        var chosen = lv.Source.ToList().Cast<string>().Where((o, idx) => lv.Source.IsMarked(idx)).ToArray();
        MessageBox.Query("

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@RetroGaming12221
Comment options

@tznind
Comment options

@RetroGaming12221
Comment options

@tznind
Comment options

@RetroGaming12221
Comment options

Answer selected by tznind
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants