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 3752378
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T09:13:59+00:00 2026-05-19T09:13:59+00:00

I’m attempting to implement a custom search dialog in a WPF program. The Parent

  • 0

I’m attempting to implement a custom search dialog in a WPF program. The Parent window is a ListView that is bound to an Observable Collection.

I’ve made a new window with the search form and it is initialized like so:

searchForm sf = new searchForm(_QPCollection);
sf.Owner = this;
sf.Show();

and I have this function I am trying to call (in the Owner window):

public void selectIndex(int index)
{
    ListViewItem toSelect = listView1.Items[index] as ListViewItem;
    toSelect.Focus();
}

Then in the Child window (searchForm) attempting to call selectIndex like so:

public void SearchJob_Click(object sender, RoutedEventArgs e)
{
    if (sJob.Text == "" || sJob.Text == null) { return; }
    for (int i = findCount; i < _QPCollectionSearch.Count; i++)
    {
        if (i == _QPCollectionSearch.Count - 1) { i = 0; }
        if (_QPCollectionSearch[i].jobNumAndFlow.IndexOf(sJob.Text) > -1)
        {
            findCount = i;
            Owner.selectIndex(i);
        }

    }
}

I get the error: System.Windows.Window does not contain a definition for “selectIndex”.

The _QPCollection is the observable collection that the search will loop through. I have the search logic working, but I cannot seem Focus() the index of the ListView in the Parent Window.

My first thought was to have a public function that I could pass the index to and it would do the focus, but I cannot seem to find a way to call function from the Child Window that are in the Parent Window.

Am I approaching this completely wrong? This answer seems to be for WinForms but I am sure there is a way to access the Parent Window and its public functions/properties in WPF.

  • 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-05-19T09:13:59+00:00Added an answer on May 19, 2026 at 9:13 am

    A cleaner way of handling that scenario would be for your searchForm to raise an event. The parent window could listen for that event and set the focus on its own list view:

    public class searchForm 
    {
        public event EventHandler<SearchEventArgs> SearchResultSelected = delegate { };
    }
    
    public class SearchEventArgs : EventArgs
    {
        public int Index { get; set; }
    }
    
    searchForm sf = new searchForm(_QPCollection);
    sf.SearchResultSelected += (s, e) => MyListView.SelectedIndex = e.Index;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a French site that I want to parse, but am running into
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
this is what i have right now Drawing an RSS feed into the php,
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti

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.