使用Timer增加sketchflow中的值 [英] Using a Timer to increment a value in sketchflow

查看:54
本文介绍了使用Timer增加sketchflow中的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 

 我是Sketchflow的新手,我想用计时器递增一个标签,使其每秒增加1,

  I am very new to sketchflow and I would like to increment a label with a timer so that it increases by 1 every second,

到目前为止,我已将Change Property动作添加到按钮中添加了一个计时器,然后我指定了我想要增加的标签,但不确定从哪里开始:\

thus far i have added the Change Property action to a button and added a timer, i then specified the label i wanted to increment but not sure where to go from here :\

任何帮助将不胜感激:)

any help would be much appreciated :)

推荐答案

我想我会使用数据存储区。您可以使用TimerTrigger + SetDataStoreValueAction来递增值,然后您的标签可以数据绑定到数据存储区。

I think I would use a datastore. You could use a TimerTrigger + SetDataStoreValueAction to increment the value, then your label could be databound to the datastore.

执行此操作的步骤:


  1. 如果需要,创建一个TextBlock(或WPF中的标签)
  2. 将SetDataStoreValueAction从资产面板拖到LayoutRoot上
  3. 选择新操作
  4. 在"属性"窗格中,按"新建"将触发器类型更改为TimerTrigger
  5. 默认为1000ms且无限
  6. In在Common Properties部分,选择Property,创建一个名为你想要的新名称,我用"LabelValue"
  7. 将Value设置为1,单击箭头查看其他属性,单击Increment,即可每次定时器触发时,将值增加1
  8. 选择TextBlock,在属性窗格中找到Text,单击旁边的框,选择Data Binding,
  9. 选择DataStore ,DataStore,您的属性(我使用LabelValue)
  10. 运行!
  1. Create a TextBlock (or label in WPF if you want)
  2. Drag a SetDataStoreValueAction from the asset panel onto LayoutRoot 
  3. Select the new action
  4. In the Properties pane, change the trigger type to TimerTrigger by pressing new
  5. It should default to 1000ms and infinite
  6. In the Common Properties section, select Property, create a new one named whatever you want, I used "LabelValue"
  7. Set the Value to 1, click the arrow to see the additional properties, click Increment, that will make it increment the value by 1 every time the timer fires
  8. Select your TextBlock, find Text in the properties pane, click the box next to it, select Data Binding,
  9. Select DataStore, DataStore, your property (I used LabelValue)
  10. Run!

以下是SL SketchFlow项目中XAML的样子(对于WPF应该是相同/非常相似的):

Here is what the XAML could look like in a SL SketchFlow project (should be the same/very similar for WPF):

<UserControl
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
	xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
	xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity" xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions"
	mc:Ignorable="d"
	x:Class="SilverlightPrototype2Screens.Screen_1"
	Width="640" Height="480">
	<UserControl.Resources>
		<ResourceDictionary>
			<ResourceDictionary.MergedDictionaries>
				<ResourceDictionary Source="ProjectDataSources.xaml"/>
			</ResourceDictionary.MergedDictionaries>
		</ResourceDictionary>
	</UserControl.Resources>

	<Grid x:Name="LayoutRoot" Background="White" DataContext="{Binding Source={StaticResource DataStore}}">
		<i:Interaction.Triggers>
			<ei:TimerTrigger>
				<ei:SetDataStoreValueAction PropertyName="LabelValue" TargetObject="{Binding Mode=OneWay, Source={StaticResource DataStore}}" Increment="True" Value="1"/>
			</ei:TimerTrigger>
		</i:Interaction.Triggers>
		<TextBlock HorizontalAlignment="Left" Height="75" Margin="46,66,0,0" Style="{StaticResource BasicTextBlock-Sketch}" TextWrapping="Wrap" Text="{Binding LabelValue}" VerticalAlignment="Top" Width="200"/>
	</Grid>
</UserControl>


这篇关于使用Timer增加sketchflow中的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆