Last Updated: February 25, 2016
·
1.725K
· davidcorne

WPF control with fixed place buttons

By this I mean you want a scalable WPF control which has controls which stay in the same place the background. For instance buttons on the same place on an image. This is important with different monitor resolutions etc.

Use a Canvas inside a Viewbox! For example a button on an image.

<Viewbox Stretch="Uniform">
      <Grid>
        <Image Source="Foot.png"/>
        <Canvas Name="KeyPointsFoot">
          <Button Background="Transparent" Canvas.Left="168" Canvas.Top="418" Width="80" Height="80">
            <Button.Content>
              <Image Source="Button.png"/>
            </Button.Content>
          </Button>
        </Canvas>
      </Grid>
    </Viewbox>

There is an example project here