当前位置:编程学习 > C#/ASP.NET >>

【wpf】帮忙看我的代码的style是哪儿有问题 谢谢

Style x:Key="ListBoxStyle" TargetType="{x:Type ListBox}">
            <Setter Property="BorderBrush" Value="Transparent"/>
            <Setter Property="KeyboardNavigation.DirectionalNavigation" Value="Cycle"/>
            <Setter Property="ItemContainerStyle">
                <Setter.Value>
                    <Style TargetType="{x:Type ListBoxItem}">
                        <Setter Property="Margin" Value="2,2,2,0"/>
                        <Setter Property="Template">
                            <Setter.Value>
                                <ControlTemplate TargetType="{x:Type ListBoxItem}">
                                    <Border Background="Transparent">
                                        <RadioButton IsHitTestVisible="False" 
                                                      Focusable="False"
                                                      IsChecked="{Binding Path=IsSelected,RelativeSource={RelativeSource TemplatedParent},Mode=TwoWay}"
                                                      Content="{TemplateBinding Content}" />   “估计是这儿有问题”
                                    </Border>
                                </ControlTemplate>
                            </Setter.Value>
                        </Setter>
                    </Style> 
                </Setter.Value>  
            </Setter>
        </Style>
///以上是style

 <ListBox  Name="ListBox1"  
  Style="{StaticResource ListBoxStyle}"   “只要我删除这一行就可以出来‘title’,所以应该是Style哪儿写错了”  
  ItemsSource="{Binding Source={StaticResource ListBoxRs},XPath=Tests/Test}"
  DisplayMemberPath="@Title" DockPanel.Dock="Left">
                
 </ListBox>

// 使用style

我说的哪一行如果不删也可以出来 但是就是没有文字 只有radioButton 

忘高手解答  小弟不胜感激



--------------------编程问答-------------------- 自己再顶 求解答····   --------------------编程问答-------------------- up
补充:.NET技术 ,  C#
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,