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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T00:41:47+00:00 2026-05-23T00:41:47+00:00

Goal: When user start typing text or characters in the textbox txtSearch the picture

  • 0

Goal:
When user start typing text or characters in the textbox txtSearch the picture picEnlarger will be hidden and be replaced by picture picXmark.
In default, the picEnlarger will always display until input data will be applied in the textbox txtSearch. In order word, no data in textbox then display picEnlarger and hide picXmark.

Problem:
Having problem to display the picture picXmark and hide the picture picEnlarger when the user start typing characters in the textbox named txtSearch.

When I tried coding in C# to gain this functionality no effect would occur in the run time.

I tried using the code:

picEnlarger = new Image();  
picXmark = new Image();

But no effect has happened.


XAML code from Stock.xaml:

<Canvas Height="39.667" Margin="8,0,215.397,0" VerticalAlignment="Top">
    <Button x:Name="btnNewProduct" Content="New" Width="75" Click="btnNewProduct_Click" Height="20.277" RenderTransformOrigin="0.667,1.726" d:LayoutOverrides="VerticalAlignment, Margin" Canvas.Left="0.001" Canvas.Top="18.723" />
    <Button x:Name="btnAddDelivery" Content="Add quantity" Width="75" Click="btnAddDelivery_Click" d:LayoutOverrides="VerticalAlignment, Margin" Height="20.277" Canvas.Left="79.001" Canvas.Top="18.723" />
    <Button x:Name="btnDeleteProduct" Content="Delete" Width="75" RenderTransformOrigin="0.107,1.843" Click="btnDeleteProduct_Click" Height="20.277" Canvas.Left="158.001" d:LayoutOverrides="HorizontalAlignment, VerticalAlignment, Width" Canvas.Top="18.723" />
    <Button x:Name="btnEdit" Content="Edit" Canvas.Left="237.001" Width="75" Canvas.Top="18.723" Click="btnEdit_Click" />
    <TextBox Name="txtSearch" Canvas.Left="391.36" TextWrapping="Wrap" Canvas.Top="18.723" Width="143.243" TextChanged="txtSearch_TextChanged" Text=" Search article" PreviewMouseLeftButtonDown="txtSearch_PreviewMouseLeftButtonDown" TextInput="txtSearch_TextInput">            
        </TextBox>

        <Label Content="Advanced Search" HorizontalAlignment="Left" Canvas.Left="444.289"/>
        <Image x:Name="picXmark" Height="8" Source="/MediaStore;component/Bilder/search_xmark.gif" Stretch="Fill" Width="8" Canvas.Left="519.853" Canvas.Top="24.167" Visibility="Hidden" />
    <Image x:Name="picEnlarger" Height="14" Canvas.Left="513.75" Source="/MediaStore;component/Bilder/search_enlarger2.gif" Stretch="Fill" Canvas.Top="21.527" Width="14" Visibility="Hidden" ImageFailed="picEnlarger_ImageFailed" />

</Canvas>

Class Stock

private void txtSearch_TextChanged(object sender, TextChangedEventArgs e)
{

    picEnlarger = new Image();
    picXmark = new Image();

    if (txtSearch.Text != "")
    {


        picEnlarger.Visibility = Visibility.Collapsed;
        picXmark.Visibility = Visibility.Visible;



        RegularSearch myRegularSearch = new RegularSearch();

        myRegularSearch.Test(txtSearch.Text);

    }
    else
    {
        picEnlarger.Visibility = Visibility.Visible;
        picXmark.Visibility = Visibility.Hidden;                
    }

}


    private void txtSearch_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
    {
        txtSearch.Text = "";
    }
  • 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-23T00:41:48+00:00Added an answer on May 23, 2026 at 12:41 am

    In theory you should be able to just use triggers for that, e.g.

    <TextBox Name="txtSearch" />
    <Image Name="ImageOne">
        <Image.Style>
            <Style TargetType="{x:Type Image}">
                <Setter Property="Visibility" Value="Visible" />
                <Style.Triggers>
                    <DataTrigger Binding="{Binding Text, ElementName=txtSearch}"
                                 Value="">
                        <Setter Property="Visibility" Value="Hidden" />
                    </DataTrigger>
                </Style.Triggers>
            </Style>
        </Image.Style>
    </Image>
    <Image Name="ImageOne">
        <Image.Style>
            <Style TargetType="{x:Type Image}">
                <Setter Property="Visibility" Value="Hidden" />
                <Style.Triggers>
                    <DataTrigger Binding="{Binding Text, ElementName=txtSearch}"
                                 Value="">
                        <Setter Property="Visibility" Value="Visible" />
                    </DataTrigger>
                </Style.Triggers>
            </Style>
        </Image.Style>
    </Image>
    

    When text is entered one image will become visible while the other one will be hidden.

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

Sidebar

Related Questions

Goal: Once i click on the start button on my user interface, i currently
On Facebook statues, you can start typing an @ and tag a user in
Goal : After user saves data to my mysql DB, a JSON teaser of
My goal: the user clicks a button. From the button pops up a two-level
My goal for now is to have a user search for other users who
My goal is to have a user select a year and a month. Translate
My goal is to let the user click on a specific location on a
My goal is to have a jQuery datepicker pop up when the user clicks
Goal To use a CREATE TYPE statement in HSQLDB 2.0.0 to create a user-defined
Goal: I'm trying to refresh content inside a div so that if the user

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.