进度条增加wihen我复选框 [英] progress bar increase wihen I check boxes
本文介绍了进度条增加wihen我复选框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个进度条和两个五个复选框。我希望每次检查一个方框时进度条的值都会增加。所以,如果我有三个盒子,我想为每个盒子增加33%的进度条。我该怎么办?我试图改变那些似乎没有我需要的东西。除非我做错了。
I have a progress bar and two-five checkboxes. I would like for the progress bar to increase in value each time I check a box. So if I have three boxes I would like to increase the progress bar 33% for each box I check. How would I do that? I triend changepropertyaction that that does not seem to have what I need. Unless I am doing it incorrectly.
推荐答案
你必须使用状态来做,但这里的代码完全在下面(同样,我用过无线电这样的按钮似乎更符合逻辑,因为只选择一个按钮。)
You'll have to do it using states but here is the code to do it all is below (also, I used radio buttons as that seems more logical since only one will be selected).
<StackPanel x:Name="LayoutRoot" Background="White">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="ProgressBar">
<VisualState x:Name="Default"/>
<VisualState x:Name="_20">
<Storyboard>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="progressBar" Storyboard.TargetProperty="(RangeBase.Value)">
<SplineDoubleKeyFrame KeyTime="00:00:00" Value="20"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="_40">
<Storyboard>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="progressBar" Storyboard.TargetProperty="(RangeBase.Value)">
<SplineDoubleKeyFrame KeyTime="00:00:00" Value="40"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="_60">
<Storyboard>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="progressBar" Storyboard.TargetProperty="(RangeBase.Value)">
<SplineDoubleKeyFrame KeyTime="00:00:00" Value="60"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="_80">
<Storyboard>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="progressBar" Storyboard.TargetProperty="(RangeBase.Value)">
<SplineDoubleKeyFrame KeyTime="00:00:00" Value="80"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="_100">
<Storyboard>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="progressBar" Storyboard.TargetProperty="(RangeBase.Value)">
<SplineDoubleKeyFrame KeyTime="00:00:00" Value="100"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<ProgressBar x:Name="progressBar" Style="{DynamicResource ProgressBar-Sketch}" Height="38" BorderThickness="1,1,1,10" Margin="0,10,312,0"/>
<RadioButton x:Name="radioButton" Style="{DynamicResource RadioButton-Sketch}" Content="0" GroupName="Progress" IsChecked="True">
<i:Interaction.Triggers>
<i:EventTrigger EventName="Click">
<pb:ActivateStateAction TargetScreen="SelectorBarTemplateSketchScreens.Screen_1_6" TargetState="Default"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</RadioButton>
<RadioButton x:Name="radioButton1" Style="{DynamicResource RadioButton-Sketch}" Content="20" GroupName="Progress">
<i:Interaction.Triggers>
<i:EventTrigger EventName="Click">
<pb:ActivateStateAction TargetScreen="SelectorBarTemplateSketchScreens.Screen_1_6" TargetState="_20"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</RadioButton>
<RadioButton x:Name="radioButton2" Style="{DynamicResource RadioButton-Sketch}" Content="40" GroupName="Progress">
<i:Interaction.Triggers>
<i:EventTrigger EventName="Click">
<pb:ActivateStateAction TargetScreen="SelectorBarTemplateSketchScreens.Screen_1_6" TargetState="_40"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</RadioButton>
<RadioButton x:Name="radioButton3" Style="{DynamicResource RadioButton-Sketch}" Content="60" GroupName="Progress">
<i:Interaction.Triggers>
<i:EventTrigger EventName="Click">
<pb:ActivateStateAction TargetScreen="SelectorBarTemplateSketchScreens.Screen_1_6" TargetState="_60"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</RadioButton>
<RadioButton x:Name="radioButton4" Style="{DynamicResource RadioButton-Sketch}" Content="80" GroupName="Progress">
<i:Interaction.Triggers>
<i:EventTrigger EventName="Click">
<pb:ActivateStateAction TargetScreen="SelectorBarTemplateSketchScreens.Screen_1_6" TargetState="_80"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</RadioButton>
<RadioButton x:Name="radioButton5" Style="{DynamicResource RadioButton-Sketch}" Content="100" GroupName="Progress">
<i:Interaction.Triggers>
<i:EventTrigger EventName="Click">
<pb:ActivateStateAction TargetScreen="SelectorBarTemplateSketchScreens.Screen_1_6" TargetState="_100"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</RadioButton>
</StackPanel>
</UserControl>
这篇关于进度条增加wihen我复选框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文