转换器/样式选择器无需绑定?
是否可以使用转换器/样式选择器而无需使用数据绑定?
如果达到某个值,我希望对象的样式发生变化。
这是我所拥有的
<Border Name="watch0_0Border" Grid.Row="0" Grid.Column="0" Style="{StaticResource clockBorderStyle}">
<StackPanel Style="{StaticResource clockStackPanelStyle}">
<TextBlock Name="watch0_0Time" Style="{StaticResource clockTimerStyle}">07:45:23</TextBlock>
<TextBlock Name="watch0_0Description" Style="{StaticResource clockTextStyle}" Text="{Binding ElementName=watch0_0WorkDescription, Path=Text}"></TextBlock>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
<Button Name="watch0_0Pause" Margin="5" Click="watch0_0Pause_Click">Pause</Button>
<Button Name="watch0_0SetNewTime" Margin="5" Click="watch0_0SetNewTime_Click">Set new time</Button>
</StackPanel>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
<TextBox Name="watch0_0Hours" Margin="5">0</TextBox>
<TextBox Name="watch0_0Minutes" Margin="5">0</TextBox>
<TextBox Name="watch0_0Seconds" Margin="5">0</TextBox>
</StackPanel>
<TextBox Name="watch0_0WorkDescription" TextAlignment="Center" Margin="5">Work description</TextBox>
</StackPanel>
</Border>
我想在时间低于 0 时调整边框的背景。
Is it possible to use a converter/style selector without having to use databinding?
I want the style of my object to change if a certain value is reached.
Here is what i have
<Border Name="watch0_0Border" Grid.Row="0" Grid.Column="0" Style="{StaticResource clockBorderStyle}">
<StackPanel Style="{StaticResource clockStackPanelStyle}">
<TextBlock Name="watch0_0Time" Style="{StaticResource clockTimerStyle}">07:45:23</TextBlock>
<TextBlock Name="watch0_0Description" Style="{StaticResource clockTextStyle}" Text="{Binding ElementName=watch0_0WorkDescription, Path=Text}"></TextBlock>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
<Button Name="watch0_0Pause" Margin="5" Click="watch0_0Pause_Click">Pause</Button>
<Button Name="watch0_0SetNewTime" Margin="5" Click="watch0_0SetNewTime_Click">Set new time</Button>
</StackPanel>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
<TextBox Name="watch0_0Hours" Margin="5">0</TextBox>
<TextBox Name="watch0_0Minutes" Margin="5">0</TextBox>
<TextBox Name="watch0_0Seconds" Margin="5">0</TextBox>
</StackPanel>
<TextBox Name="watch0_0WorkDescription" TextAlignment="Center" Margin="5">Work description</TextBox>
</StackPanel>
</Border>
I want to canhe the background of the border when the times goes under 0.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您的计时器可以访问主窗口(可以访问 watch0_0Border)或直接 watch0_0Border(通过在创建计时器时传递这些),那么您应该能够在计时器时使用 UI 调度程序来设置 watch0_0Border.BorderBrush (或任何属性)为零。
If your timer has access to main window (which can access watch0_0Border) or watch0_0Border direct (by passing these in when timer was created) then you should just be able to use the UI dispatcher to set watch0_0Border.BorderBrush (or whatever property) when timer hits zero.