wpf - Animate from one style to another -


If someone wants to animate from one genre to another, then he is thinking that going from ordinary to style to Activist, when the user focuses on the text box.

  & lt; Style x: key = "normal style" target type = "{x: type text box}" & gt; & Lt; Setter Property = "Borderbrush" Value = "Gray" /> & Lt; Setter Property = "Frontline" value = "2" /> & Lt; / Style & gt; & Lt; Style x: key = "ActiveStyle" TargetType = "{x: type text box}" based on = "{static resource normal style}" & gt; & Lt; Setter Property = "Borderbrush" Value = "Green" /> & Lt; Setter Property = "Frontline" value = "4" /> & Lt; / Style & gt;  

If you want to swap the whole style, then I think you In the code:

  & lt; StackPainel & gt; & Lt; Text box style = "{static resource common style}" GotFocus = "TextBox_GotFocus" LostFocus = "TextBox_LostFocus" /> & Lt; Text box style = "{static resource common style}" GotFocus = "TextBox_GotFocus" LostFocus = "TextBox_LostFocus" /> & Lt; / StackPanel & gt;  
  Personal style focused style; Personal style general style; Public Manvindo () {Initialization (); Focusing style = SearchResource ("ActiveStyle") style; General Style = Discoverrsource ("normal style") style; } Private Zero TextBox_GotFocus (Object Sender, RoutedEventArgs e) {(Textbox Sender). .Style = focusStyle; } Private Zero TextBox_LostFocus (Object Sender, RoutedEventArgs e) {(Textbox Sender). Style = normal style; }  

Otherwise, you are limited to triggering back and forth.

  & lt; Text box text = "1" & gt; & Lt; TextBox.Style & gt; & Lt; Style based on = "{static resource common style}" target type = "{x: type text box}" & gt; & Lt; Style.Triggers & gt; & Lt; Event Trigger Routing Avent = "Gotofocus" & gt; & Lt; BeginStoryboard & gt; & Lt; Storyboard & gt; & Lt; Color animation storyboard Target = property = "green" = "0: 0: 0.1" /> for "borderbrush color". & Lt; / Storyboard & gt; & Lt; / BeginStoryboard & gt; & Lt; / EventTrigger & gt; & Lt; Event Trigger Routing Avent = "LostFocus" & gt; & Lt; BeginStoryboard & gt; & Lt; Storyboard & gt; & Lt; Color animation storyboard Targetproperty = = "gray" period = "0: 0: 0.1" /> for "borderbrush color." & Lt; / Storyboard & gt; & Lt; / BeginStoryboard & gt; & Lt; / EventTrigger & gt; & Lt; /Style.Triggers> & Lt; / Style & gt; & Lt; / Textbox.Style  

Comments

Popular posts from this blog

c# - ListView onScroll event -

PHP - get image from byte array -

Linux Terminal Problem with Non-Canonical Terminal I/O app -