Wpf XAML ListView项已启用
我有以下XAML:Wpf XAML ListView项已启用,wpf,xaml,listview,isenabled,Wpf,Xaml,Listview,Isenabled,我有以下XAML: <Grid Grid.Row="3" Margin="8,8"> <Grid.RowDefinitions> <RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/> <RowDefi
<Grid Grid.Row="3" Margin="8,8">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<!-- Setting 'UsingItems' here -->
<CheckBox Grid.Row="0"
IsChecked="{Binding Path=UsingItems}"
Content="{Binding Path=IncludeItemsText}" />
<!-- This works as expected -->
<CheckBox Grid.Row="1"
IsEnabled="{Binding Path=UsingItems}"/>
<!-- This doesn't! Even though the ListView becomes enabled the Items aren't and the Checkboxes are not checkable! -->
<ListView Grid.Row="2" IsEnabled="{Binding Path=UsingItems}"
VerticalAlignment="Stretch"
ItemsSource="{Binding Path=SortedItems}">
<ListView.ItemTemplate>
<DataTemplate>
<DockPanel>
<CheckBox
IsChecked="{Binding Path=.IsSelected}"
Margin="0,2" Click="CheckBox_Click" />
<TextBlock
Text="{Binding Path=.Item.ItemDescription}"
Margin="4,0,0,0"
VerticalAlignment="Top">
</TextBlock>
</DockPanel>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</Grid>
如果属性“UsingItems”=false,我想禁用ListView中的所有项UsingItems'是使用第0行中的复选框设置的,我已通过在第1行中设置一个虚拟复选框确认了这一点-IsEnabled属性已按预期设置
但是,当“UsingItems”=true时,即使ListView已启用(并且项“look”已启用),ListView项仍保持禁用状态
我曾假设IsEnabled属性会过滤掉树,但这里没有发生这种情况
我哪里做错了
谢谢
Joe您是否在ViewModel类上实现了
INPC
,并在其setter上引发了PropertyChanged
事件?我在小样本中对其进行了测试,效果良好。ListViewItems正在与ListView本身一起启用。谢谢-您可以单击listViewItem内的复选框吗?是的,我可以单击<代码>绑定对于内部复选框-IsChecked=“{Binding Path=.IsSelected}”
谢谢,当我保存项目时,退出表单,然后重新编辑,ListViewItems可按预期编辑。。一定是我的初始化有问题,我还没弄明白:-/