wpf - Focus on Label, TextBlock and Border -


I want to create a flat button with round right top and bottom corners. On clicking and on the mouse this button needs to be changed in the background.

At present my markup looks like this:

  & lt; Border x: name = "MyButton" Height = "25" margin = "0,5,0,0" corner Radius = "0 5 5 0" borderTechnness = "1" borderbrush = "gray" style = "{static resources mystyle 1 } "& Gt; & Lt; StackPanel Orientation = "Horizontal" margin = "8,0,0,0" & gt; & Lt; Image source = "image.jpg" height = "20" /> & Lt; Textbox text = "my button" /> & Lt ;! - If label is required then there may be a label - & gt; & Lt; / StackPanel & gt; & Lt; / Border & gt; & Lt; Style x: key = "myStyle1" TargetType = "{x: type limit}" & gt; & Lt; Setter Property = "Background" Value = "{StaticRSORS Main ContentActivator Collar}" /> & Lt; Style.Triggers & gt; & Lt; Trigger Property = "Ismouth Over" Value = "True" & gt; & Lt; Setter property = "background" value = "red" /> & Lt; / Catalyst & gt; & Lt; /Style.Triggers> & Lt; / Style & gt;  

The mouse trigger works perfectly but I can not get the trigger triggered to work ... I've tried IsKeyboardFocusWithin and IsFocused but it is not working.

If you can create a button style, then property will only issue you. See the code below using VSM.

  & lt; Style x: key = "buttonstyle1" targettype = "{x: type button}" & gt; & Lt; Setter Estates = "Template" & gt; & Lt; Setter.Value & gt; & Lt; ControlTemplate TargetType = "{x: type button}" & gt; & Lt; Grid & gt; & Lt; VisualStateManager.VisualStateGroups & gt; & Lt; VisualState Group x: Name = "General Location" & gt; & Lt; VisualState X: Name = "General" /> & Lt; VisualState X: Name = "mouseover" & gt; & Lt; Storyboard & gt; & Lt; ColorAnimationUsingKeyFrames Beginner Time = "00:00:00" Duration = "00: 00: 00.0010000" Storyboard Target = "border" storyboard. Targetproperty = "(border boardbrush). (SolidColorBrush.Color)" & gt; & Lt; SplineColorKeyFrame KeyTime = "00:00:00" value = "# FF 760DD" /> & Lt; / ColorAnimationUsingKeyFrames & gt; & Lt; / Storyboard & gt; & Lt; / VisualState & gt; & Lt; VisualState X: Name = "Pressed" & gt; & Lt; Storyboard & gt; & Lt; ColorAnimationUsingKeyFrames Beginner Time = "00:00:00" Duration = "00: 00: 00.0010000" Storyboard Target = "border" storyboard. Targetproperty = "(border boardbrush). (SolidColorBrush.Color)" & gt; & Lt; SplineColorKeyFrame KeyTime = "00:00:00" value = "# FF 675A88" /> & Lt; / ColorAnimationUsingKeyFrames & gt; & Lt; / Storyboard & gt; & Lt; / VisualState & gt; & Lt; / VisualStateGroup & gt; & Lt; /VisualStateManager.VisualStateGroups> & Lt; Border x: name = "border" borderbrush = "#ff5a8876" bordertyxize = "3" background = "#fff4 4" /> & lt; Content Viewer Horizontal Alignment = "Center" Vertical Element = "Center" SnapTwoVideo Pixel = "{TemplateBinding SnapsToDevicePixels}" RecognizesAccessKey = "True" /> & Lt; / Grid & gt; & Lt; / ControlTemplate & gt; & Lt; /Setter.Value> & Lt; / Setter & gt; & Lt; / Style & gt; & Lt; Button horizontal alignment = "left" style = "{DynamicResource ButtonStyle1}" vertical alignment = "top" width = "180" height = "61" content = "button" />  

Comments

Popular posts from this blog

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -