Creating a clickable image in WPF

mico picture mico · Apr 27, 2010 · Viewed 40.4k times · Source

I want to make a user control that shows an image and can invoke a command when clicked. Later I want to bind a list of these controls to a list of products.

Answer

GibboK picture GibboK · Feb 6, 2014

Try this very straight forward approach

<Grid>
        <Button Height="50" Width="50">
            <Button.Template>
                <ControlTemplate>
                    <Image Source="yourimage.png"/>
                </ControlTemplate>
            </Button.Template>
        </Button>

    </Grid>

private void Button_Click(object sender, RoutedEventArgs e)
        {
           // do smt
        }