ListBox
의 스타일을 지정하고 그 주위에 Border
을 표시하고 싶습니다.WPF ListBox 트리거가 IsFocused 속성에서 작동하지 않습니다.
<Trigger Property="IsFocused" Value="True">
<Setter Property="Visibility" TargetName="border" Value="Collapsed"/>
</Trigger>
똑같은 나는 또한 TextBox
에 사용하고하고 올바르게 작동 : 나는 ListBox
가 포커스를 취득했을 때에이 Border
을 숨기려. Trigger
이 ListBox
에서 작동하지 않는 이유는 무엇입니까?
편집 :
나는 나의 ListBox
이 Style
을 데 : 나는 또한 문제가 제대로 작동하기 위해 예를 받고 있고 있었다
<ControlTemplate TargetType="{x:Type local:ListBox}">
<Border SnapsToDevicePixels="true" x:Name="Bd" CornerRadius="5"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}" Padding="1">
<Grid>
<local:ScrollViewer Focusable="false" Padding="{TemplateBinding Padding}">
<ItemsPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
</local:ScrollViewer>
<Border CornerRadius="5" Background="Red" x:Name="border">
<TextBlock VerticalAlignment="Center" FontWeight="Bold" Foreground="White"
Text="{TemplateBinding Message}" FontFamily="Courier New" />
</Border>
</Grid>
</Border>
</DockPanel>
<ControlTemplate.Triggers>
<Trigger Property="IsFocused" Value="True">
<Setter Property="Visibility" TargetName="border" Value="Collapsed"/>
</Trigger>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Background" TargetName="Bd"
Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"/>
</Trigger>
<Trigger Property="IsGrouping" Value="true">
<Setter Property="ScrollViewer.CanContentScroll" Value="false"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
더 많은 문맥을 제공해 주시겠습니까? 스타일 정의를 표시 할 수 있습니까? 목록 상자와 텍스트 상자에 스타일을 적용하는 방법은 무엇입니까? – Anton
내 코드 질문을 업데이트했습니다. – viky