Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
swdev:dotnet:focus_scopes [2010/12/09 10:12] smayr created |
swdev:dotnet:focus_scopes [2010/12/09 10:29] (current) smayr [Logical Focus] |
||
---|---|---|---|
Line 1: | Line 1: | ||
== Focus Scopes == | == Focus Scopes == | ||
- | Sometimes, controls need to be grouped into focus scopes so that there is always a focused control in that group, irrespective of the actual keyboard focus (there can only be one keyboard focused control in an application at any given time). | + | Sometimes, controls need to be grouped into focus scopes so that there is always a logically |
- | To create a focus scope, make a parent control: | + | === Logical Focus === |
+ | To create a logical | ||
<code xml> | <code xml> | ||
< | < | ||
< | < | ||
< | < | ||
- | < | + | < |
</ | </ | ||
</ | </ | ||
+ | Programmatically, | ||
+ | <code csharp> | ||
+ | StackPanel pnlsideButtonsMain= new StackPanel(); | ||
+ | FocusManager.SetIsFocusScope(pnlsideButtonsMain, | ||
+ | </ | ||
+ | |||
+ | To set the focus in a control (eg. a button, in this case called '' | ||
+ | <code csharp> | ||
+ | // Sets the focused element in focus scope pnlsideButtonsMain | ||
+ | // pnlsideButtonsMain is a StackPanel. | ||
+ | FocusManager.SetFocusedElement(pnlsideButtonsMain, | ||
+ | </ | ||
+ | |||
+ | === Focus Styles === | ||
+ | |||
+ | To style a control to show keyboard focus and logical focus: | ||
+ | <code xml> | ||
+ | <Style x: | ||
+ | <Setter .../> | ||
+ | <Setter .../> | ||
+ | <Setter Property=" | ||
+ | < | ||
+ | < | ||
+ | <Border ... | ||
+ | x: | ||
+ | CornerRadius=" | ||
+ | BorderThickness=" | ||
+ | BorderBrush=" | ||
+ | < | ||
+ | Margin=" | ||
+ | HorizontalAlignment=" | ||
+ | VerticalAlignment=" | ||
+ | RecognizesAccessKey=" | ||
+ | </ | ||
+ | < | ||
+ | < | ||
+ | <Trigger Property=" | ||
+ | <Setter TargetName=" | ||
+ | <Setter TargetName=" | ||
+ | <Setter Property=" | ||
+ | </ | ||
+ | < | ||
+ | <Trigger Property=" | ||
+ | <Setter TargetName=" | ||
+ | <Setter TargetName=" | ||
+ | <Setter Property=" | ||
+ | </ | ||
+ | ... | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | == References == | ||
+ | * [[http:// |