Hi I have a little problem.
I’m using data binding to retrieve data from an internet source..
All goes wel and the data is perfectly presented in a textblock that resides within an data template.
So far so good..
I’m trieng to use the if statement on that textblock
like:
if (textblock.Text == ("good")
{Do some stuff here}
I’ve added an Loaded event handler to the textblock and now I’m able to do:
private void loadedevent_Loaded(object sender, RoutedEventArgs e)
{
var textBlock = sender as TextBlock;
if (1 == 1)
{
textBlock2.Text = textBlock.Text;
}
}
I did that just to see if the text gets copied over to textBlock2. (So I know that works)
and here comes the problem:
When I say:
private void loadedevent_Loaded(object sender, RoutedEventArgs e)
{
var textBlock = sender as TextBlock;
if (textBlock.Text == "good")
{
do some stuff here
}
}
It just wont trigger and I’m 1000% sure that the text inside the textblok == “good”
Please help been.. fighting with this for over 2 days…
Try using textblock.Text.Trim().Equals(“good”)
Also as someone else has said, Loaded is probably called before the data gets loaded. Try using the Shown event or the Textbox change event.
Cheers!