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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T12:46:56+00:00 2026-05-18T12:46:56+00:00

I’m currently learning how to develop and building an app for windows phone 7.

  • 0

I’m currently learning how to develop and building an app for windows phone 7.

If a certain value is true, I need to add a TextBlock to the ListBox before a TextBlock (say its name is x:Name="dayTxtBx").

I am currently using

dayListBox.Items.Add(dayTxtBx);

to add the text box.

Any help very much appreciated!

Thanks

  • 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-18T12:46:56+00:00Added an answer on May 18, 2026 at 12:46 pm

    This is pretty easy to do if you’re using a DataTemplate and a ValueConverter and passing the whole object into the ListBox (rather than just a string). Assuming you have some object that looks like:

    public class SomeObject: INotifyPropertyChanged
    {
        private bool mTestValue;
        public bool TestValue 
        {
            get {return mTestValue;}
            set {mTestValue = value; NotifyPropertyChanged("TestValue");}
        }
        private string mSomeText;
        public string SomeText
        {
            get {return mSomeText;}
            set {mSomeText = value; NotifyPropertyChanged("SomeText");}
        }
    
        public event PropertyChangedEventHandler PropertyChanged;
        private void NotifyPropertyChanged(string name)
        {
            if ((name != null) && (PropertyChanged != null))
            {
                PropertyChanged(this, new PropertyChangedEventArgs(name));
            }
        }
    }
    

    You can make a converter that looks like:

    public class BooleanVisibilityConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (value != null && (bool)value)
                return Visibility.Visible;
            else
                return Visibility.Collapsed;
        }
        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
    

    And add the converter to your XAML like so:

    <UserControl x:Class="MyProject.MainPage"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="clr-namespace:MyProject">
        <UserControl.Resources>
            <local:BooleanVisibilityConverter x:Key="BoolVisibilityConverter" />
        <UserControl.Resources>
    

    Then you could have the ListBox defined in XAML like so:

    <Listbox>
      <Listbox.ItemTemplate>
        <DataTemplate>
          <StackPanel Orentation="Horizontal" >
            <TextBlock Text="Only Show If Value is True" Visibility={Binding TestValue, Converter={StaticResource BoolVisibilityConverter}} />
            <TextBlock Text="{Binding SomeText}" />
          </StackPanel>
        </DataTemplate>
      </Listbox.ItemTemplate>
    </Listbox>
    

    Might seem like a lot, but it’s really pretty simple once you get started. A great way to learn more about data binding and converters is at Jesse Liberty’s blog ( http://jesseliberty.com/?s=Windows+Phone+From+Scratch ).

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

Sidebar

Related Questions

No related questions found

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.