1
내 WPF 목록 상자에 대한 스타일을 정의했지만 직접 맨 위에 사각형을 추가하고 있습니다 ... 그 자체를 목록 상자 자체로 만드는 방법은 무엇입니까? ListBox에 사각형 추가
스타일리스트 박스 나는 효과를 얻기 위해 현재해야 할 일은
<Style BasedOn="{StaticResource {x:Type ListBox}}"
TargetType="ListBox"
x:Key="PinnedList">
<Setter Property="Background">
<Setter.Value>
<LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1">
<LinearGradientBrush.GradientStops>
<GradientStop Offset="0.0" Color="#90DDDD" />
<GradientStop Offset="1.0" Color="#5BFFFF" />
</LinearGradientBrush.GradientStops>
</LinearGradientBrush>
</Setter.Value>
</Setter>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ListBox">
<Border Name="Border" Background="{StaticResource WhiteSolid}" BorderBrush="{StaticResource GreatTeaHeaderBrush}" BorderThickness="4" CornerRadius="2">
<ScrollViewer Margin="0" Focusable="false">
<StackPanel Margin="2" IsItemsHost="True" />
</ScrollViewer>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
(구형 : 그래서 현재 내가 최종 효과를 그 아래에 목록 상자를 추가 한 후 구형의 XAML을 작성하고 목록 상자) :
<Rectangle Height="20" Width="20" Fill="{StaticResource GreenTeaBrush}" Margin="-7,37,129,0" VerticalAlignment="Top" x:Name="ui_recPinnedORGs">
<Rectangle.LayoutTransform>
<RotateTransform Angle="-45"/>
</Rectangle.LayoutTransform>
</Rectangle>
<ListBox Style="{StaticResource PinnedList}" Height="Auto" MaxHeight="200" Visibility="Hidden" HorizontalAlignment="Left" Margin="-8,45,0,0" SelectionChanged="ui_lsbPinnedORGs_SelectionChanged"
SelectedItem="{Binding Path=SelectedPinnedORGsViewModel, UpdateSourceTrigger=PropertyChanged, NotifyOnSourceUpdated=True, NotifyOnTargetUpdated=True, Mode=TwoWay}"
SelectionMode="Single" ItemsSource="{Binding Path=ORGViewModels, UpdateSourceTrigger=PropertyChanged, NotifyOnSourceUpdated=True, NotifyOnTargetUpdated=True, Mode=TwoWay}"
ScrollViewer.HorizontalScrollBarVisibility="Disabled" ScrollViewer.VerticalScrollBarVisibility="Auto"
VerticalAlignment="Top" Width="158" Name="ui_lsbPinnedORGs">
<ListBox.ItemTemplate>
<HierarchicalDataTemplate>
<Label Content="{Binding Path=ORG.Acronym, UpdateSourceTrigger=PropertyChanged, NotifyOnSourceUpdated=True}" />
</HierarchicalDataTemplate>
</ListBox.ItemTemplate>
</ListBox>
ListBoxItem (ListBox 아님)에 대한 스타일 시도 – Paparazzi
감사합니다. Blam,하지만 아래 답변은 정상적으로 작동합니다. :) –