tags:

views:

48

answers:

2

I have an application that replaces a physical function keyboard with keys on the screen. Example of existing application Existing application

Now I locate all the buttons in the window with code and it is rather slow. So I wonder if I can solve this with WPF. Unfortunately, I am new to WPF and wondering how I should proceed.

Requirements

  1. Location of the buttons in the grid shall be optional
  2. The color of the buttons and the text should be optional
  3. The buttons must either be able to contain text or icons
  4. When the window resize, buttons shall be scaled up with the same position in the grid.
  5. When the button is scaled up, the text and icon also scaled up

When some buttons are pressed of the user, they remain pressed until certain conditions are met. When a button remains depressed, it must be particularly clear, for example, by inverted colors.

+1  A: 

Have a look at Christian Moser's WPF Tutorial, especially the part in Layout -> Grid Panel.

It will be some work creating the XAML for your entire Grid, but afterwards it should perform well. Doing this will solve your point 1-4 (use ToggleButtons and the .Stretch Alignments for these), I am not sure yet what to do about 5. =)

Jens
Scaling could be done by putting the content of the ToggleButton into a ViewBox. Performance-wise, YMMV, but generally for something of this size it should be ok.
Wonko the Sane
For 5, it might be a good idea to handle resizing by setting `LayoutTransform` of the whole thing to `ScaleTransform`.
svick
A: 

You should ook into ToggleButton, its Content property and HorizontalAlignment.Stretch (/Vertical)

Veer