---
title: "WPF Image Command Binding"  
description: "WPF Image Command Binding"  
author: "Anonymous User"  
published: 2013-09-25  
updated: 2013-09-25  
canonical: https://www.mindstick.com/forum/1526/wpf-image-command-binding  
category: "wpf"  
tags: ["wpf"]  
reading_time: 1 minute  

---

# WPF Image Command Binding

I'm putting a WPF [application](https://www.mindstick.com/articles/12824/calculator-application-in-android) [together](https://yourviews.mindstick.com/view/80819/live-in-relationship-protecting-the-right-to-live-together) in which I have an [image control](https://www.mindstick.com/forum/95341/how-can-use-upload-image-control-in-asp-dot-net) which I want to bind a [custom](https://www.mindstick.com/blog/12298/use-custom-writing-services-to-get-through-the-finals) [command object](https://answers.mindstick.com/qa/116279/explain-the-executenonquery-executescalar-and-executereader-methods-of-the-command-object) to from my view model that will [execute](https://www.mindstick.com/interview/49/how-can-i-execute-a-php-script-using-command-line) when the image is clicked. I have [exposed](https://yourviews.mindstick.com/view/80962/kerala-healthcare-legend-exposed-amidst-coronavirus-pandemic) the command object from my [view model](https://www.mindstick.com/forum/160237/explain-razor-view-model-binding-how-does-it-work-and-why-is-it-important) and just need to bind it to the image control.

Is it possible to bind this command object to an image control? If so any advice would be appreciated.

## Replies

### Reply by Anonymous User

**Hi Goti,**

It can be simpler to avoid using a button and use a Hyperlink instead:

```
<TextBlock DockPanel.Dock="Top">   <Hyperlink Command="{Binding SomeCommand}">      <Image Source="image.png" />   </Hyperlink></TextBlock>
```

Note that this will render the hyperlink with the default text decoration, so you'll want to add a style that removes that - putting this in the resource dictionary of the containing element will do the trick:

```
<Style x:Key={x:Type Hyperlink}" TargetType="Hyperlink">   <Setter Property="TextDecorations"           Value="{x:Null}" />   </Style></Style>
```


---

Original Source: https://www.mindstick.com/forum/1526/wpf-image-command-binding

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
