【问题标题】:Bind the text field content to Ok button of RadWindow将文本字段内容绑定到 RadWindow 的 Ok 按钮
【发布时间】:2016-02-16 07:40:22
【问题描述】:

在我使用 C# 和 WPF 基于 MVVM 架构构建的应用程序中,我使用 RadWindow 提示用户输入带有 Ok & Cancel 选项的文件名。

我希望能够根据用户输入启用/禁用或可见/不可见确定按钮。

例如: 输入的文件名 -> 确定按钮启用/可见

文件名为空 -> 确定按钮已禁用/不可见。

我怎样才能实现这种行为?

【问题讨论】:

    标签: c# wpf mvvm telerik radwindow


    【解决方案1】:

    Telerik RadPrompt 窗口有一个自定义 Template,其中包含一个 TextBox 和两个 Buttons。要根据TextBox的输入启用或禁用Button,可以在OKButtonIsEnabled属性中添加Binding

                        <telerik:RadButton x:Name="OK"
                                Command="{x:Static telerik:WindowCommands.Confirm}"
                                telerikNavigation:RadWindow.ResponseButton="Accept"
                                MinWidth="70"
                                IsTabStop="True"
                                TabIndex="1"
                                HorizontalAlignment="Right"
                                telerik:LocalizationManager.ResourceKey="Ok"
                                Margin="0 10 8 8"
                                IsEnabled="{Binding ElementName=PromptTextBox,Path=Text.Length}" />
    

    【讨论】:

    • 谢谢!这很简单。我应该再挖一点。
    猜你喜欢
    • 2011-05-22
    • 1970-01-01
    • 2018-09-03
    • 1970-01-01
    • 1970-01-01
    • 2012-02-10
    • 1970-01-01
    • 2018-10-24
    • 1970-01-01
    相关资源
    最近更新 更多