2
votes

I have a listbox with attribute ItemsSource="{Binding}", and I have placed few text blocks in it e-g. status, name, date etc. I am setting it itemsource programmatically like this.

listBox.ItemsSource = SomeController.GetSomeList();

Status field is a boolean field in my class model and I want to display open and close in Status fields rather than showing true and false but i dont find any event where I can do this. We dont have any event like onrowcreated or something like this where I can change the attributes of textblock according to its value.

Thanks Yama, but i have found an easier solution my self :)

I set the text block with data which is coming from my model class and describe a loaded event in my CS file. and In that event I wrote

   if (Boolean.Parse(((TextBlock)sender).Text) == true)
        {
            ((TextBlock)sender).Text = "Opened";
        }
        else
        {
            ((TextBlock)sender).Text = "Closed";
        }

and I can change all of the textblock's attribute as I want through this.

1
Consider using IValueConverter windowsphonegeek.com/articles/…onmyway133
Thanks Yama, but i have found an easier solution my self :) I set the text block with data which is coming from my model class and describe a loaded event in my CS file. and In that event I wrote if (Boolean.Parse(((TextBlock)sender).Text) == true) { ((TextBlock)sender).Text = "Opened"; } else { ((TextBlock)sender).Text = "Closed"; } and I can change all of the textblock's attribute as I want through this.Samee Mir

1 Answers

0
votes

Thanks Yama, but i have found an easier solution my self :) I set the text block with data which is coming from my model class and describe a loaded event in my CS file. and In that event I wrote

if (Boolean.Parse(((TextBlock)sender).Text) == true) { ((TextBlock)sender).Text = "Opened"; } else { ((TextBlock)sender).Text = "Closed"; } and I can change all of the textblock's attribute as I want through this