本文介绍了如何从自定义控件更改样式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 亲爱的, 下图中的Bqse我需要执行一些网格动画才能显示UI的左侧或右侧部分: 如果你看一下图片的顶部,这个是我的初始状态。一个占用整个网格的UserControl,最初用3列构建。 然后,如果我点击按钮1,我应该能够为第一列设置动画,以便左边部分得到显示并获取userControl1。对于按钮2相同 然后,如果我再次单击按钮,左右部分将被隐藏,并且相应地缩放中心usercontrol 如何正确实现这个按钮行为是为了为主网格的左右列设置动画? 任何样本都会很感激 问候解决方案 按钮? Button1和Button2? 我通过usingToggleButton为你做参考。< Window.Resources> < Style TargetType =" ToggleButton"> < Style.Triggers> < Trigger Property =" ToggleButton.IsChecked"值= QUOT;真"> < Trigger.EnterActions> < BeginStoryboard> < Storyboard> < DoubleAnimation Storyboard.TargetProperty =" Width" From =" 130" To ="50" 持续时间=" 0:0:3" /> < / Storyboard> < / BeginStoryboard> < /Trigger.EnterActions> < Trigger.ExitActions> < BeginStoryboard> < Storyboard> < DoubleAnimation Storyboard.TargetProperty =" Width" From =" 50" To =" 130" 持续时间=" 0:0:3" /> < / Storyboard> < / BeginStoryboard> < /Trigger.ExitActions> < / Trigger> < /Style.Triggers> < / Style> < /Window.Resources> < Grid> < Grid.ColumnDefinitions> < ColumnDefinition Width =" Auto" /> < ColumnDefinition /> < ColumnDefinition Width =" Auto" /> < /Grid.ColumnDefinitions> < ToggleButton Content =" 1"字号= QUOT; 30英寸;宽度= QUOT; 130" Grid.Column = QUOT; 0" /> < StackPanel Grid.Column =" 1"背景= QUOT;绿色" /> < ToggleButton Content =" 2"字号= QUOT; 30英寸;宽度= QUOT; 130" Grid.Column = QUOT; 2英寸/> < / Grid> 希望这就是你想要的。 此致, Bob Dear all,Bqse on the picture below I need to perform some grid animation in order to display the left or right part of the UI :If you look at the top part of the picture, this is the initial state I have. A UserControl which occupy the full grid which is initially build with 3 columns.Then if I click on Button 1 , I should be able to animate the first column in order that the left part gets displayed and get userControl1 visible. Same for button 2Then if I click again on buttons, left and right part gets hiden and center usercontrol scaled accordinglyHow can I implement correctly this button behavior in order to animate left and right column of the main grid ?Any sample would be appreciateregards 解决方案 Hi,Where is the button? Button1 and Button2?I make a sample by usingToggleButton for you reference. <Window.Resources> <Style TargetType="ToggleButton"> <Style.Triggers> <Trigger Property="ToggleButton.IsChecked" Value="True"> <Trigger.EnterActions> <BeginStoryboard> <Storyboard > <DoubleAnimation Storyboard.TargetProperty="Width" From="130" To="50" Duration="0:0:3" /> </Storyboard> </BeginStoryboard> </Trigger.EnterActions> <Trigger.ExitActions> <BeginStoryboard> <Storyboard > <DoubleAnimation Storyboard.TargetProperty="Width" From="50" To="130" Duration="0:0:3" /> </Storyboard> </BeginStoryboard> </Trigger.ExitActions> </Trigger> </Style.Triggers> </Style> </Window.Resources> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto"/> <ColumnDefinition/> <ColumnDefinition Width="Auto"/> </Grid.ColumnDefinitions> <ToggleButton Content="1" FontSize="30" Width="130" Grid.Column="0"/> <StackPanel Grid.Column="1" Background="Green"/> <ToggleButton Content="2" FontSize="30" Width="130" Grid.Column="2"/> </Grid>Hope this is what you want.Sincerely,Bob 这篇关于如何从自定义控件更改样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-24 01:35