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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T16:00:41+00:00 2026-05-24T16:00:41+00:00

For adding some images to a WrapPanel, I’m trying to iterate through a collection.

  • 0

For adding some images to a WrapPanel, I’m trying to iterate through a collection. My TileCollection contains instances of a Tile class which has a ImageSource property.

I’ve got it by doing all the stuff step by step – Create a new image 1, assign all the properties, create a bew binding 1, assign binding 1 to image 1, add image 1 to the panel, proceed with image 2, … tons of code I want to shorten now. Here is what I’ve got so far:

For Each tile As Tile In TileCollection
     MainPanel.Children.Add(New Image With {.Width = 80, .Height = 80, .Margin = New Thickness(10), .SetBinding = New Binding With {.Source = tile, Path = New PropertyPath("ImageSource"), .Mode = BindingMode.Default, .UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged)}})
Next

1) .”SetBinding” doesn’t work in object initializer expression. Is there any workaround?

2) Is there any way to add a handler in object initializer expression, for e.g. capturing mousedown events?

thx

  • 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-24T16:00:41+00:00Added an answer on May 24, 2026 at 4:00 pm

    You can create extension methods on the objects that you need that do what you want and then return the self instance again to allow chaining, effectively creating a fluent interface. You then call these methods after the object initializer expression.

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

Sidebar

Related Questions

I am having some problems. Basically I am adding images which are loaded via
I'm adding some lazy initialization logic to a const method, which makes the method
so I am trying to drag around some images in a canvas. I am
I am using the jQuery cycle plugin to cycle through some images. These images
I was adding some images to buttons and when i complied then suddenly errors
I am adding some images to a div from a database in the Page_Load()
I am adding some user controls dynamically to a PlaceHolder server control. My user
I'm currently adding some new extended classes to this code: foreach (BaseType b in
I was thinking of adding some Achievements to our internal bug-tracking and time logging
I'm adding some functionality to my site so that users can upload their own

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.