I am creating a WPF dialog. It is like our normal messagebox
with ok
and cancel
button. How to create such a dialog so that the Ok
button is selected when the dialog is opened?
相关问题
- Sorting 3 numbers without branching [closed]
- Graphics.DrawImage() - Throws out of memory except
- Why am I getting UnauthorizedAccessException on th
- 求获取指定qq 资料的方法
- How to know full paths to DLL's from .csproj f
just create a new button template and change the look and feel for the IsDefault=Tue state. I just created a style and modified the state.
To set a Window's Default button
Set your default button's IsDefault property to true.
Note that you can also set a Window's Cancel button by setting a button's IsCancel property to true.
To set the Selected (focused) button in a Window
If you want to select a particular button then use the Focus method like this:
You might do this when a Window loads (in the Window_Loaded event).
To select a particular button when your Window opens make sure its IsTabStop property is set to true and ensure its TabIndex property is lower than any other control on the Window.