专注收集记录技术开发学习笔记、技术难点、解决方案
网站信息搜索 >> 请输入关键词:
您当前的位置: 首页 > .NET Framework

WPF中的Menu控件解决思路

发布时间:2011-06-23 14:01:53 文章来源:www.iduyao.cn 采编人员:星星草
WPF中的Menu控件
如题,设置了一个Menu控件  ,  之后绑定数据之后 由于数据过多 都已经排出窗体 甚至屏幕了  怎么解决这个问题呢?谢谢各位先
------解决方案--------------------
引用:
Quote: 引用:

你这叫菜单吗? 没有二级菜单,可以重写它的模块,改成Listbox显示列表。


数据绑定如何实现?



 <Style  x:Key="itemStyle" TargetType="{x:Type MenuItem}">
            <Setter Property="FontSize" Value="14"/>
            <Setter Property="Height" Value="30"></Setter>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate  TargetType="{x:Type MenuItem}">
                        <DockPanel>
                            <ContentPresenter x:Name="Icon" Content="{TemplateBinding Icon}" ContentSource="Icon" Margin="4,0,6,0" VerticalAlignment="Center"/>
                            <Path x:Name="GlyphPanel" Data="M0,2 L0,4.8 L2.5,7.4 L7.1,2.8 L7.1,0 L2.5,4.6 z" Fill="{TemplateBinding Foreground}" FlowDirection="LeftToRight" Margin="4,0,6,0" Visibility="Collapsed" VerticalAlignment="Center"/>
                            <!--显示内容-->
                            <Border x:Name="B_MenuItem" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" BorderBrush="Blue" BorderThickness="1" Width="90" Height="60">
                                <TextBlock Text="{TemplateBinding Header}"/>
                            </Border>
                            <Popup x:Name="PART_Popup" AllowsTransparency="True" Focusable="False" HorizontalOffset="-1" VerticalOffset="0" IsOpen="{Binding IsSubmenuOpen, RelativeSource={RelativeSource TemplatedParent}}" PopupAnimation="{DynamicResource {x:Static SystemParameters.MenuPopupAnimationKey}}" Placement="Bottom" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" MaxHeight="150">
                                <Border x:Name="B"  HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
                                    <ScrollViewer x:Name="SubMenuScrollViewer" Style="{DynamicResource {ComponentResourceKey ResourceId=MenuScrollViewer, TypeInTargetAssembly={x:Type FrameworkElement}}}">
                                        <Grid RenderOptions.ClearTypeHint="Enabled">
                                            <!--阴影矩形-->
                                            <Rectangle x:Name="OpaqueRect" Fill="{Binding Background, ElementName=SubMenuBorder}"/>
                                            <Border BorderBrush="Brown" BorderThickness="1" Background="DarkGray">
                                                <ItemsPresenter x:Name="ItemsPresenter" KeyboardNavigation.DirectionalNavigation="Cycle" Grid.IsSharedSizeScope="True" KeyboardNavigation.TabNavigation="Cycle"/>
友情提示:
信息收集于互联网,如果您发现错误或造成侵权,请及时通知本站更正或删除,具体联系方式见页面底部联系我们,谢谢。

其他相似内容:

热门推荐: