I have a ListBox that I need to disable when it is disabled. At the user's request, this is not enough to turn it off, but it should also look different. shrugs. I looked in several other places and followed examples, and it seems that it should work, but it is not. Here are a few examples that I looked at: Example1 , Example2 .
Here is my code:
<Style x:Key="ListBoxStyle" TargetType="ListBox"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type ListBox}"> <ControlTemplate.Triggers> <Trigger Property="IsEnabled" Value="False"> <Setter Property="BorderBrush" Value="Black"></Setter> <Setter Property="Foreground" Value="LightGray"></Setter> <Setter Property="Background" Value="LightGray"></Setter> <Setter Property="BorderBrush" Value="LightGray"></Setter> </Trigger> </ControlTemplate.Triggers> </ControlTemplate> </Setter.Value> </Setter> </Style>
It looks pretty simple. I have successfully completed the same basic process on ComboBox and TextBox . Can someone help me see where my code is wrong? An example of how to do it right will be great. The first example above seemed to be exactly what I needed, but the correct answer: βThe only way to do this is to override the templateβ, which does not help me.
I have already tried some simple solutions. Perhaps some other style may influence this, because we work with several different Resource Dictionaries. Does anyone know what could be a good way to keep track of this?
Edit: I searched the entire solution, and the only place the ListBox is used is my part, and the only place it was written in is the styles that I set. According to MSDN , there are no "parts" of the ListBox, so this is not possible. I inadvertently styled part of the ListBox in the process style for another control. Without styling, when I turn off the ListBox, it is frozen, but visible without text and has a default background. When I try to apply Property = "Background" Value = "LightGray", it seems hidden (i.e. Nothing is visible). If anyone knows why he can do this or how to complete my task, I would appreciate help.
source share