开发者

How to hide texblock if the text string value is equal to zero?

开发者 https://www.devze.com 2023-02-02 17:24 出处:网络
I’d like to have the texblock is not visible if the value that generated dynamically is equal 开发者_Python百科to zero. I think it can be done solely in XAML using DataTrigger. I am wondering if some

I’d like to have the texblock is not visible if the value that generated dynamically is equal 开发者_Python百科to zero. I think it can be done solely in XAML using DataTrigger. I am wondering if someone can help to find the proper solution for this. Thank you in advance.


If you just want to hide the textbox based on the value of that same textbox you could use something like the code below.

<TextBox Text="0">
    <TextBox.Style>
        <Style>
            <Style.Triggers>
                <DataTrigger Binding="{Binding RelativeSource={RelativeSource Mode=Self},Path=Text}" Value="0">
                    <Setter Property="UIElement.Visibility" Value="Hidden" />
                </DataTrigger>
            </Style.Triggers>
        </Style>
    </TextBox.Style>
</TextBox>

You can add in a binding if you wanted. Also if you need to check the value of a different textbox to determine if this one should be shown you can alter the binding on the DataTrigger.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号