[英]Bind the text field content to Ok button of RadWindow
在使用C#和WPF基於MVVM體系結構構建的應用程序中,我使用RadWindow提示用戶使用“ 確定”和“取消”選項輸入文件名。
我希望能夠根據用戶輸入啟用/禁用 “確定”按鈕或使之可見/不可見 。
例如:輸入文件名->確定按鈕已啟用/可見
文件名為空->確定按鈕已禁用/不可見。
我該如何實現這種行為?
Telerik RadPrompt
窗口具有一個自定義Template
,該Template
包含一個TextBox
和兩個Buttons
。 要基於TextBox
的輸入啟用或禁用Button
,可以將Binding
添加到OK Button
的IsEnabled
屬性:
<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.