簡體   English   中英

將文本字段內容綁定到RadWindow的“確定”按鈕

[英]Bind the text field content to Ok button of RadWindow

在使用C#和WPF基於MVVM體系結構構建的應用程序中,我使用RadWindow提示用戶使用“ 確定”和“取消”選項輸入文件名。

我希望能夠根據用戶輸入啟用/禁用 “確定”按鈕或使之可見/不可見

例如:輸入文件名->確定按鈕已啟用/可見

文件名為空->確定按鈕已禁用/不可見。

我該如何實現這種行為?

Telerik RadPrompt窗口具有一個自定義Template ,該Template包含一個TextBox和兩個Buttons 要基於TextBox的輸入啟用或禁用Button ,可以將Binding添加到OK ButtonIsEnabled屬性:

                    <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}" />

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM