转换器/样式选择器无需绑定?

发布于 2024-12-13 08:59:40 字数 1869 浏览 0 评论 0原文

是否可以使用转换器/样式选择器而无需使用数据绑定?

如果达到某个值,我希望对象的样式发生变化。

这是我所拥有的

    <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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

超可爱的懒熊 2024-12-20 08:59:40

如果您的计时器可以访问主窗口(可以访问 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文