選擇任何其他專案(如單選按鈕專案)后,我試圖禁用/灰色組合框。我使用 Visual Studio 創建了 WPF 表單并在 PowerShell 中使用了相同的 xaml 表單。因此,后端是基于選擇執行的 PowerShell 函式。一個這樣的要求是當我在組合框上選擇一個單選按鈕時獲取資料。在組合框中選擇的專案應與其他組合框專案匹配,否則我的功能將不起作用。我面臨的問題是我無法禁用/灰顯它,即使我嘗試通過在 PowerShell 中設定專案 isenable=$false 來嘗試。如果我在 XAML 中設定相同,它可以作業,但它不滿足要求,否則我將無法選擇專案。這是代碼
<RadioButton Name="Radio_VM" Content="ASR Status" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="30,382,0,0" RenderTransformOrigin="0.133,0.393"/>
<ComboBox Name="Client" HorizontalAlignment="Left" Margin="15,230,0,0" VerticalAlignment="Top" Width="120" IsDropDownOpen="False" SelectedIndex="2" >
<ComboBoxItem Content="ABC"/>
<ComboBoxItem Content="DEF"/>
</ComboBox>
一旦我選擇單選按鈕,它應該灰色組合框。
uj5u.com熱心網友回復:
您可以使用 aStyle與 aDataTrigger系結到 的IsChecked屬性RadioButton:
<ComboBox Name="Client" HorizontalAlignment="Left" Margin="15,230,0,0" VerticalAlignment="Top" Width="120" IsDropDownOpen="False" SelectedIndex="2">
<ComboBox.Style>
<Style TargetType="ComboBox">
<Style.Triggers>
<DataTrigger Binding="{Binding IsChecked, ElementName=Radio_VM}" Value="True">
<Setter Property="IsEnabled" Value="False" />
</DataTrigger>
</Style.Triggers>
</Style>
</ComboBox.Style>
<ComboBoxItem Content="ABC"/>
<ComboBoxItem Content="DEF"/>
</ComboBox>
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/431121.html
上一篇:路徑最大寬度
