I am new to WPF I have 15 grids on my grid and I have a small menu on which I click I can choose whether to show or hide the grid only one grid at one time I will have to throw out the grid when it is pressed on Esc I have all the animations already, let me know Need to know how the grid is showing at this time (active)
I do not know how to get the current maximum control of my window.
My solution is when the KeyDown
event is triggered in my window:
Private Zero Windows_KeyDown (Object Sender, System. Windows.Input.KeyEventArgs e) {if (E.Key == System.Windows.Input.Key.Escape) {// Check all the grids for Isisisible and start the same thing that is true, do theStistboard . Fund Resources ("The Whizzine On_Hide")); Actually, I think this means that whose keyboard focus is on If this is the case, then the following control will return that is currently the keyboard input focus: System.Windows.Input.Keyboard.FocusedElement
You can use:
if (E.K. == System.indust.industry.secope) {// Check for all the grid for Isvigible and which is correct Is that var selected = forms of keyboard grid Focus Element in; If return (selected == blank); Selected.BeginStoryboard ((Storyboard) this.FindResource ("HideGrid")); }
An approach which will be more decoupled will be to create a static enclosed dependency property that can be used in this way (untested):
& Lt; Grid Local: extensions.HideOnEscape = "true" .... />
A very difficult implementation will look like this:
public class extension {hide static for public static reading Hide Escache Property = Dependencies. Registrant ("hidden area", type of bool), typef (extension), new UIPpropy metadata (false, hiddenOnExtension_set)); Public static zero SetHideOnEscape (dependency object obj, boolean value) {obj.SetValue (HideOnEscapeProperty, value); } Public Stable Bull GetHideOnEscape (Dependent Object OBJE) {Return (BULL) obj.GetValue (HideOnEscapeProperty); } Private Static Zero HideOnExtensions_Set (Dependency Object D, Dependency Property Entanglement E) {Var Grid = Grid as D; If (grid! = Null) {grid.KeyUp + = Grid_KeyUp; }} Private Static Zero Grid_KeyUp (Object Sender, KeyEventArgs E) {// Check for Escape Key ... var Grid = Sender as Grid; // Create an animation in the code, or a resource exists (grid.FindResource ()) // Apply the animation to the grid}}
This will remove the code requirement in codebehind.
Comments
Post a Comment