开发者

Arrange buttons in a grid with WPF

开发者 https://www.devze.com 2023-01-06 06:32 出处:网络
I have an application that replaces a physical function keyboard with keys on the screen. Example of existing application

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

  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.


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)

0

精彩评论

暂无评论...
验证码 换一张
取 消