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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T19:51:11+00:00 2026-05-15T19:51:11+00:00

So I have a Listbox: <ListBox Grid.Row=0 Grid.Column=1 Grid.RowSpan=2> //<—-Item’s Data Source Method Call

  • 0

So I have a Listbox:

<ListBox Grid.Row="0" Grid.Column="1" Grid.RowSpan="2"> //<----Item's Data Source Method Call Here?
    <ListBox.ItemsPanel>
        <ItemsPanelTemplate>
            <VirtualizingStackPanel
             Orientation="Horizontal"
             IsItemsHost="true"  />
        </ItemsPanelTemplate>
     </ListBox.ItemsPanel>
     <ListBox.ItemTemplate>
       <DataTemplate>
          <StackPanel Grid.Row="0" Grid.Column="1" Grid.RowSpan="2" Orientation="Vertical">
             <Label Content="{Binding Address1}"></Label>
             <Label Content="{Binding Address2}"></Label>
             <Label Content="{Binding Town}"></Label>
             <Label Content="{Binding Postcode}"></Label>
             <Label Content="{Binding Country}"></Label>
             <CheckBox Content="{Binding Include}"></CheckBox>
          </StackPanel>
       </DataTemplate>
     </ListBox.ItemTemplate>
</ListBox>

What I would like to do is set the item’s data source to a list of addresses all of which have the same postal code. So I need a list of the current addresses in an Observable Collection with the same postcode. To generate such a list of addresses would only take a call to a method which accepts the current postcode as a an argument but I don’t know how to call a method that requires an argument from a static datasource.

Can anyone help?

  • 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-15T19:51:12+00:00Added an answer on May 15, 2026 at 7:51 pm

    Create a view with a Collection property and a PostCode property. Bind the PostCode TwoWay, let the setter raise OnPropertyChanged for the Collection property, and let the collection property return a collection based on the current value of the PostCode property.

    internal class MyView : INotifyPropertyChanged {
       private string _postCode;
    
       public string PostCode {
          get { return _postCode; }
          set {
             _postCode = value;
             OnPropertyChanged("PostCode");
             OnPropertyChanged("FilteredItems");
          }
       }
    
       public ObservableCollection<Address> Items { get; set; }
    
       public IEnumerable<Address> FilteredItems {
          get { return Items.Where(o => o.PostCode == _postCode).ToArray(); }
       }
    
       public event PropertyChangedEventHandler PropertyChanged;
    
       private void OnPropertyChanged( string propertyName ) {
          if( PropertyChanged != null ) {
             PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
          }
       }
    }
    
    <Grid DataContext="{Binding Path=myViewInstance}">
       <TextBox Text="{Binding Path=PostCode, Mode=TwoWay}"/>
       <ListBox Grid.Row="0" Grid.Column="1" Grid.RowSpan="2" ItemsSource="{Binding Path=FilteredItems}">
          <ListBox.ItemsPanel>
             <ItemsPanelTemplate>
                <VirtualizingStackPanel
                   Orientation="Horizontal"
                   IsItemsHost="true"  />
             </ItemsPanelTemplate>
          </ListBox.ItemsPanel>
          <ListBox.ItemTemplate>
             <DataTemplate>
                <StackPanel Grid.Row="0" Grid.Column="1" Grid.RowSpan="2" Orientation="Vertical">
                   <Label Content="{Binding Address1}"></Label>
                   <Label Content="{Binding Address2}"></Label>
                   <Label Content="{Binding Town}"></Label>
                   <Label Content="{Binding PostCode}"></Label>
                   <Label Content="{Binding Country}"></Label>
                   <CheckBox Content="{Binding Include}"></CheckBox>
                </StackPanel>
             </DataTemplate>
          </ListBox.ItemTemplate>
       </ListBox>
    </Grid>
    

    Note: My “Address” class might differ from yours.

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

Sidebar

Related Questions

I have horizontal ListBox. Here is code for it (removed some irrelevant): <ListBox Grid.Row=1
I have the following DataTemplate in a Listbox <ListBox Grid.Column=1 Grid.Row=2 ItemsSource={Binding People} SelectedItem={Binding
In xaml, I have a listbox with a grid in it with 1 row
I have a listbox defined in XAML as: <ListBox x:Name=directoryList MinHeight=100 Grid.Row=0 ItemsSource={Binding Path=SelectedDirectories}/>
So I have this Xaml inside a ListBox Item Template: <ListBox.ItemTemplate> <DataTemplate> <Grid Height=22
I have a ListBox : <ListBox x:Name=HistogramListBox Grid.Column=1 Margin=8,2,8,0 HorizontalAlignment=Stretch VerticalAlignment=Stretch Template={StaticResource HistogramListBoxControlTemplate} ItemContainerStyle={StaticResource
I have the following listbox on my page: <ListBox Grid.Row=1 Name=SlideSelectorListBox SelectedItem={Binding SelectedSlide} SelectedIndex={Binding
I have a Listbox as so: xmlns:local=clr-namespace:MyGui.Controls <ListBox Grid.Row=1 ItemsSource={Binding MyData} x:Name=MyDataContainer> <ListBox.ItemTemplate> <DataTemplate>
I have listbox that displays information about list of objects: <ListBox Grid.Column=0 Height=152 Name=CustomersList
I have a listbox with a datatemplate <Button Name=ButtonSortDate Content=Date Grid.Column=1 Click=ButtonSortDateClick /> <Button

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.