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

  • SEARCH
  • Home
  • 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 7954707
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T03:30:45+00:00 2026-06-04T03:30:45+00:00

I am trying to do: bool hasXItems = (grid.SelectedItems as IEnumerable<Y>).Any(i => ((Y) i).IsX);

  • 0

I am trying to do:

bool hasXItems = (grid.SelectedItems as IEnumerable<Y>).Any(i => ((Y) i).IsX);

This does not seem to work (result of casting is null). How can I query the DataGrid.SelectedItems with Linq?

This is the property I’m querying: http://msdn.microsoft.com/en-us/library/system.windows.controls.primitives.multiselector.selecteditems(v=vs.90).aspx

  • 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-04T03:30:47+00:00Added an answer on June 4, 2026 at 3:30 am

    I cant make out from your comment what you want to do but you can use LINQ this way.

    DataGridRow[] results = datagrid.SelectedItems
                                    .OfType<DataGridRow>()
                                    .Where(x => ((bool)x.IsFocused))
                                    .ToArray();
    

    It will iterate through all selected Rows and return that rows which are focused.

    This query has 4 sections

    1. datagrid.SelectedItems. This line will give all selected rows as a list because SelectedItems returns an IList object.

    2. .OfType<DataGridRow>() . This line will return all selected rows returned from line 1 as DataGridRow.

    3. .Where(x => ((bool)x.IsFocused)). This line will iterate over all DataGridRows returned from Line 2 to find which rows is focused.

    4. .ToArray(). This line will convert all of DatagridRows which are focused returned by Line 3 to Array and put it in the results variable.

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

Sidebar

Related Questions

I'm trying to figure out what this piece of code does: std::vector<std::vector<bool> > visited(rows,
I'm trying to get integer or bool from database result this way: bool tblexist
Trying to mock the following method: bool IsLoginValid(LoginViewModel viewModel, out User user); Tried this
I am new to linq.. this is what i am trying to do bool
I'm trying to do something like this: class foo { virtual void bool operator==(foo
I have this code I am trying to send one more bool value to
When I'm trying to do this to get the BOOL from a dictionary, I
I get a compiler error when trying to synthesize a bool array like this:
I am trying to validate a URL with this method: Code: - (BOOL) validateUrl:
I am trying to convert my nullable bool value and I am getting this

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.