Arrange buttons in a grid with WPF
I have an application that replaces a physical function keyboard with keys on the screen. Example of existing application Existing application http://img823.imageshack.us/img823/2750/keyemexample.jpg
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
- Location of the buttons in the grid shall be optional
- The color of the buttons and the text should be optional
- The buttons must either be able to contain text or icons
- When the window resize, buttons shall be scaled up with the same position in the grid.
- 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.
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. =)
You should ook into ToggleButton, its Content property and HorizontalAlignment.Stretch (/Vertical)
精彩评论