멋진 모양을 만들려고합니다. Listbox
. ListBoxItem
은 선택 후 확장해야하지만 문제는 특정 항목에 대한 세부 정보가 담긴 ListBox
을 포함하고 있다고 가정하고 일부 데이터를 입력하는 방법을 모릅니다. C# 코드에서 액세스하여 XAML에서 바인딩하려고 시도했지만 아직 솔루션 근처에 아무 것도 없습니다.WPF : ListBoxItem에 배치 된 ListBox에 데이터 삽입
<UserControl.Resources>
<ResourceDictionary>
<DataTemplate x:Key="SelectedTemplate">
<StackPanel Orientation="Vertical">
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Path = Order}" Style="{StaticResource SampleListCellItem}" MinWidth="35"/>
<TextBlock Text="{Binding Path = FullName}" Style="{StaticResource SampleListCellItem}" Width="340"/>
<TextBlock Text="{Binding Path = FirstName}" Style="{StaticResource SampleListCellItem}" Width="200" />
<TextBlock Text="{Binding Path = BirthDate, StringFormat = d}" Style="{StaticResource SampleListCellItem}" Width="100"/>
</StackPanel>
<StackPanel HorizontalAlignment="Right">
<ListBox Name="InnerList" Height="200" Width="200"/>
<Button Name="Button1" Height="40" Width="100" Content="ButtonText" Visibility="Visible"/>
</StackPanel>
</StackPanel>
</DataTemplate>
<DataTemplate x:Key="ItemTemplate">
<StackPanel Orientation="Vertical">
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Path = Order}" Style="{StaticResource SampleListCellItem}" MinWidth="35"/>
<TextBlock Text="{Binding Path = FullName}" Style="{StaticResource SampleListCellItem}" Width="340"/>
<TextBlock Text="{Binding Path = FirstName}" Style="{StaticResource SampleListCellItem}" Width="200" />
<TextBlock Text="{Binding Path = BirthDate, StringFormat = d}" Style="{StaticResource SampleListCellItem}" Width="100"/>
</StackPanel>
</StackPanel>
</DataTemplate>
<Style TargetType="{x:Type ListBoxItem}" x:Key="ContainerStyle">
<Setter Property="ContentTemplate" Value="{StaticResource ItemTemplate}"/>
<Style.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter Property="ContentTemplate" Value="{StaticResource SelectedTemplate}"/>
</Trigger>
</Style.Triggers>
</Style>
</ResourceDictionary>
</UserControl.Resources>
답변 해 주셔서 감사 드리며 답변을 늦게 드려 죄송합니다. 데이빗의 해결책은 매력처럼 작동합니다. 감사 – Seldon