0
我有這個標記,當它的IsEnabled = false時,我的背景顏色不會保持爲null。我嘗試了一種樣式觸發器,它在變成禁用狀態時會改變它,但它沒有奏效。如何使我的ListView背景顏色爲空時,其禁用GridView?WPF不能用gridview改變listview背景
<ListView Background="{x:Null}" IsEnabled="False">
<ListView.View>
<GridView>
<GridViewColumn Header="First Name" DisplayMemberBinding="{Binding FirstName}"/>
<GridViewColumn Header="Last Name" DisplayMemberBinding="{Binding LastName}"/>
<GridViewColumn Header="Email" DisplayMemberBinding="{Binding EmailAddress}"/>
</GridView>
</ListView.View>
<ListView.ItemContainerStyle>
<Style TargetType="ListViewItem">
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
</Style>
</ListView.ItemContainerStyle>
</ListView>
在App.xaml中
<Style TargetType="ListView">
<Setter Property="BorderThickness" Value="0"/>
<Style.Triggers>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Background" Value="Transparent" />
</Trigger>
</Style.Triggers>
</Style>
你使用MVVM? – Bigeyes
是的,我願意。/\/\ / – shady