Skip to content

Commit efbd418

Browse files
committed
Lower opacity when ListBox not enabled
1 parent 331ec1b commit efbd418

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

MainDemo.Wpf/Lists.xaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,22 @@
1414
</ResourceDictionary>
1515
</UserControl.Resources>
1616
<Grid Margin="8">
17+
<Grid.RowDefinitions>
18+
<RowDefinition/>
19+
<RowDefinition Height="Auto"/>
20+
</Grid.RowDefinitions>
1721
<Grid.ColumnDefinitions>
1822
<ColumnDefinition Width="1*" />
1923
<ColumnDefinition Width="1*" />
2024
<ColumnDefinition Width="1*" />
2125
</Grid.ColumnDefinitions>
22-
<ListBox Grid.Column="0">
26+
<ListBox Grid.Column="0" IsEnabled="{Binding IsChecked, ElementName=EnableListBox}">
2327
<TextBlock>Plain</TextBlock>
2428
<TextBlock>Old</TextBlock>
2529
<TextBlock>ListBox</TextBlock>
2630
<TextBlock>Full of junk</TextBlock>
2731
</ListBox>
32+
<CheckBox Name="EnableListBox" Grid.Row="1" IsChecked="True">Enabled</CheckBox>
2833
<!-- piece together your own items control to create some nice stuff that will make everyone think you are cool. and rightly so, because you are cool. you might even be a hipster for all I know -->
2934
<ItemsControl Grid.Column="1" ItemsSource="{Binding Items1}"
3035
Grid.IsSharedSizeScope="True"

MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.ListBox.xaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,9 @@
133133
<Trigger Property="IsSelected" Value="True">
134134
<Setter TargetName="Ripple" Property="Opacity" Value=".92" />
135135
</Trigger>
136+
<Trigger Property="IsEnabled" Value="False">
137+
<Setter Property="Opacity" Value=".56" />
138+
</Trigger>
136139
</ControlTemplate.Triggers>
137140
</ControlTemplate>
138141
</Setter.Value>
@@ -270,6 +273,11 @@
270273
Padding="{TemplateBinding Padding}"/>
271274
</Grid>
272275
</Border>
276+
<ControlTemplate.Triggers>
277+
<Trigger Property="IsEnabled" Value="False">
278+
<Setter Property="Opacity" Value=".56" />
279+
</Trigger>
280+
</ControlTemplate.Triggers>
273281
</ControlTemplate>
274282
</Setter.Value>
275283
</Setter>

0 commit comments

Comments
 (0)