wpf - Hide breadcrumb items when longer than container -


i've created breadcrumb in xaml using listbox control. works nicely. however, when try show add many items, naturally shows of them. want somehow hide left-hand items until right element visible. ideally should leave free space (on right) too. how can this?

                <listbox height="80" horizontalalignment="stretch" x:name="breadcrumb"             minwidth="300" background="transparent" borderthickness="0"             scrollviewer.horizontalscrollbarvisibility="hidden" scrollviewer.verticalscrollbarvisibility="hidden">                     <listbox.itemspanel>                         <itemspaneltemplate>                             <stackpanel margin="8,0,0,0" orientation="horizontal" horizontalalignment="stretch" background="transparent">                             </stackpanel>                         </itemspaneltemplate>                     </listbox.itemspanel>                     <listbox.itemcontainerstyle>                         <style targettype="listboxitem">                             <setter property="background" value="#111"/>                             <setter property="borderbrush" value="#aaa"/>                             <setter property="horizontalcontentalignment" value="center"/>                             <setter property="verticalcontentalignment" value="center"/>                             <setter property="padding" value="0"/>                             <setter property="template">                                 <setter.value>                                     <controltemplate targettype="listboxitem">                                         <stackpanel orientation="horizontal" margin="-8,0,0,0">                                             <image source="assets/breadcrumb.png" verticalalignment="center" margin="5,0,0,0"/>                                             <contentpresenter />                                         </stackpanel>                                     </controltemplate>                                 </setter.value>                             </setter>                         </style>                     </listbox.itemcontainerstyle>                     <listbox.itemtemplate>                         <datatemplate>                             <stackpanel verticalalignment="stretch">                                 <textblock fontsize="35" text="{binding name}" verticalalignment="center" padding="5,10"/>                             </stackpanel>                         </datatemplate>                     </listbox.itemtemplate>                 </listbox> 

you may need build custom panel listbox.itemspaneltemplate. required functionality created quite in manner able measure each breadcrumb rendered , show ones fit.

if have no experience of yet, don't put off... can achieve wonderful things custom panels. here articles if need them:

panels overview (msdn),

how create custom layout panel in wpf

creating custom panels in wpf


Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

c# - must be a non-abstract type with a public parameterless constructor in redis -

ajax - PHP/JSON Login script (Twitter style) not setting sessions -