【问题标题】:Border for UI feedback using binding使用绑定的 UI 反馈边框
【发布时间】:2012-08-23 19:39:55
【问题描述】:

.NET/C#/WPF 菜鸟在这里。我正在尝试根据我可以绑定的变量(变量存储验证结果)为文本框提供边框。我的第一次尝试是这样的:

<Border ... Visibility="{Binding ServerName.IsValid, Converter={StaticResource BoolToVisibility}}">
    <TextBox ... />
</Border>

但是当可见性被隐藏时,这具有隐藏文本框的不良副作用。之后我查看了 DataTriggers,但它似乎不是我需要的。关于如何将边框绑定到该变量的任何想法?

谢谢!

【问题讨论】:

    标签: c# .net wpf xaml data-binding


    【解决方案1】:

    你可以分层:

    <Grid>
        <Border ... /> <!-- Bind as before -->
        <TextBox Margin="5"/> <!-- Margin to not completely hide border below -->
    </Grid>
    

    (如果需要,您也可以通过切换顺序来覆盖边框)


    您也可以使用DataTrigger,但您需要更改外观而不是完全隐藏它。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-02-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多