在WP7中,我有一个列表框,其中包含在列表框样式模板中定义的寻呼机。从代码访问我的寻呼机控件的最佳方法是什么?我需要根据datacontext中的记录数显示/隐藏ListPagerPanel。
<ListBox x:Name="StreamListBox" ItemsSource="{Binding Mode=OneWay}">
<ListBox.Resources>
<Style x:Key="ListBoxStyle1" TargetType="ListBox">
<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Disabled"/>
<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ListBox">
<ScrollViewer x:Name="ScrollViewer" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Foreground="{TemplateBinding Foreground}" Padding="{TemplateBinding Padding}">
<StackPanel>
<ItemsPresenter/>
<StackPanel x:Name="ListPagerPanel" HorizontalAlignment="Right" Orientation="Horizontal">
....等等谢谢
答案 0 :(得分:4)
您可以使用类似的代码片段以动态方式实现样式 Style = Application.Current.Resources [“StreamListBox”]为Style