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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T18:01:21+00:00 2026-05-10T18:01:21+00:00

I am just starting out with Silverlight (2 RC0) and can’t seem to get

  • 0

I am just starting out with Silverlight (2 RC0) and can’t seem to get the following to work. I want to create a simple image button user control.

My xaml for the user control is as follows:

 <Button>         <Button.Template>                <ControlTemplate>                 <Image Source='{TemplateBinding ImageSource}' Width='{TemplateBinding Width}' Height='{TemplateBinding Height}' />             </ControlTemplate>         </Button.Template>     </Button> 

The code behind is as follows:

public partial class ImageButtonUserControl : UserControl     {         public ImageButtonUserControl()         {             InitializeComponent();         }          public Image Source         {             get { return base.GetValue(SourceProperty) as Image; }             set { base.SetValue(SourceProperty, value); }         }         public static readonly DependencyProperty SourceProperty =              DependencyProperty.Register('SourceProperty', typeof(Image), typeof(ImageButtonUserControl),null);     } 

I want to be able to dynamically create the ImageButtons and stuff them in a container like a WrapPanel: Assume we have an image named “image” already:

ImageButtonUserControl imageButton = new ImageButtonUserControl(); imageButton.Source = image; this.thumbnailStackPanel.Children.Add(imageButton); 

What do I need to do to get the image to display? I’m assuming I need to do something with DataContext, but I’m not quite sure what or where.

Thanks for any 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. 2026-05-10T18:01:21+00:00Added an answer on May 10, 2026 at 6:01 pm

    You can get an ImageButton easily just by templating an ordinary Button so you dont require a UserControl at all. Assuming that Button.Content will be the ImageSource. The ControlTemplate of the Button will be:

     <ControlTemplate x:Key='btn_template'>             <Image Source='{TemplateBinding Content}' />     </ControlTemplate> 

    And the usage as an ItemsControl with URL collection as its ItemsSource, You can add WrapPanel as the ItemPanel. Default will be StackPanel if you don’t specify one.

    <DataTemplate x:Key='dataTemplate'>   <Button Template='{StaticResource btn_template}' Content='{Binding}'/> </DataTemplate>        <ItemsControl ItemsSource='{Binding UrlCollection}' ItemsTemplate='{StaticResource dataTemplate}'/> 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Just starting out with canvas and javascript and can't get my head around why
Just starting out, this should be a simple one but I haven't been able
I'm just starting out using Lua, and I was wondering (because I can't find
I am just starting out on Silverlight using version 2.0. I wanted to show
Just starting out to program in python and I'm having the following issue. I
Just starting out with C#, so this may be overly simple that I keep
Just starting out with LINQ to SQL (you can probably tell - be gentle).
I'm just starting out with D3.js . I've created a simple enough donut chart
I'm just starting out on a component for Joomla. I can't figure out how
Just starting out in the world of web development... so I'm hoping you can

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.