locked
Firing an event when the value of textblock changes in windows store apps RRS feed

  • Question

  • Hi,

    I want to fire an event when the value of my textblock changes in windows store app.

    Not able to find a suitable one that gets fired when the value of my textblock changes.

    Can somebody tell me if an event exists for this or not.

    Monday, September 23, 2013 10:59 AM

Answers

  • Hi,

    I want to fire an event when the value of my textblock changes in windows store app.

    Not able to find a suitable one that gets fired when the value of my textblock changes.

    Can somebody tell me if an event exists for this or not.

    TextBlock or TextBox?

    Khant Nipun answer above how to raise TextBox textchanged event. Is it what you need?


    Monday, September 23, 2013 11:12 AM
  • Hello Naveen,

    Try this for textbox:

    <TextBox x:Name="txt1" Width="300" TextChanged="txt1_TextChanged_1"/>
    
      private void txt1_TextChanged_1(object sender, TextChangedEventArgs e)
            {
    Debug.WriteLine("text changed");
            }

    Try this for textblock, it fires 2 times, when your page is loaded & when your textvalue change :

    <TextBlock x:Name="tbl1" Text="sample" Width="125" VerticalAlignment="Center" FontSize="15" SizeChanged="tbl1_SizeChanged_1" />

    code:

      private void tbl1_SizeChanged_1(object sender, SizeChangedEventArgs e)
            {
    Debug.WriteLine("text changed");
            }
    
    protected override void OnNavigatedTo(NavigationEventArgs e)
            {
                tbl1.Text = "test";
            }

    Monday, September 23, 2013 11:34 AM

All replies

  • Hi,

    I want to fire an event when the value of my textblock changes in windows store app.

    Not able to find a suitable one that gets fired when the value of my textblock changes.

    Can somebody tell me if an event exists for this or not.

    TextBlock or TextBox?

    Khant Nipun answer above how to raise TextBox textchanged event. Is it what you need?


    Monday, September 23, 2013 11:12 AM
  • Hello Naveen,

    Try this for textbox:

    <TextBox x:Name="txt1" Width="300" TextChanged="txt1_TextChanged_1"/>
    
      private void txt1_TextChanged_1(object sender, TextChangedEventArgs e)
            {
    Debug.WriteLine("text changed");
            }

    Try this for textblock, it fires 2 times, when your page is loaded & when your textvalue change :

    <TextBlock x:Name="tbl1" Text="sample" Width="125" VerticalAlignment="Center" FontSize="15" SizeChanged="tbl1_SizeChanged_1" />

    code:

      private void tbl1_SizeChanged_1(object sender, SizeChangedEventArgs e)
            {
    Debug.WriteLine("text changed");
            }
    
    protected override void OnNavigatedTo(NavigationEventArgs e)
            {
                tbl1.Text = "test";
            }

    Monday, September 23, 2013 11:34 AM