2
我想根據ListBoxItem的內容的IsEnabled屬性來禁用ListBox項目。就像在這段代碼中,按鈕1有IsEnabled = False,但是列表框項是可選的。如果內容IsEnabled屬性爲false,我想禁用選擇。如何觸發搜索項目內容及其IsEnabled屬性。如何在觸發器ListBoxItem中找到子控件的IsEnabled屬性
<Grid>
<ListBox>
<ListBox.ItemTemplate>
<DataTemplate>
<DataTemplate.Triggers>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="IsEnabled" Value="False"/>
</Trigger>
</DataTemplate.Triggers>
</DataTemplate>
</ListBox.ItemTemplate>
<ListBoxItem>
<Button IsEnabled="False">1</Button>
</ListBoxItem>
<ListBoxItem>
<Button>2</Button>
</ListBoxItem>
<ListBoxItem>
<Button>3</Button>
</ListBoxItem>
</ListBox>
</Grid>
中的同一個屬性上,但這不是我想要實現的。我想獲得子控件的IsEnabled屬性。 我正在使用MVVM,但我想在我的資源字典中使用觸發器。 – DronBoard 2012-03-21 13:58:19