欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

WPF学习

程序员文章站 2022-07-13 23:14:26
...

ListBox绑定详细

                <ListBox ItemsSource="{Binding Nav}">
                    <ListBox.ItemContainerStyle>
                        <Style TargetType="ListBoxItem" BasedOn="{StaticResource MaterialDesignListBoxItem}">
                            <Setter Property="FontWeight" Value="Bold"/>
                            <Setter Property="FontSize" Value="15"/>
                            <Setter Property="Height" Value="50"/>
                            <Setter Property="Padding" Value="0"/>
                            <Style.Triggers>
                                <Trigger Property="IsMouseOver" Value="True">
                                    <Setter Property="Background" Value="#F5F5F5"/>
                                </Trigger>
                                <Trigger Property="IsSelected" Value="True">
                                    <Setter Property="Foreground" Value="#00A1D6"/>
                                    <Setter Property="Background" Value="Transparent"/>
                                </Trigger>
                            </Style.Triggers>
                        </Style>
                    </ListBox.ItemContainerStyle>
                    <ListBox.ItemTemplate>
                        <DataTemplate>
                            <RadioButton  Width="210" Command="{Binding DataContext.ItemClick,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=ListBox}}"  CommandParameter="{Binding}">
                                <RadioButton.Style>
                                    <Style>
                                        
                                    </Style>
                                </RadioButton.Style>
                                <StackPanel Orientation="Horizontal">
                                    <TextBlock Text="{Binding Name}"/>
                                </StackPanel>
                            </RadioButton>
                        </DataTemplate>
                    </ListBox.ItemTemplate>
                </ListBox>
相关标签: WPF wpf