WPF ListBox: Vertical scrollbar and focus -
i have 2 problems regarding listbox/wrappanel.
first of all, setup: in xaml have listbox. inside of listbox wrappanel. programatically add listboxitems wrappanel.
problem one
the listboxitems [stackpanel image , textblock] fills left right , down. however, vertical scrollbar not appear if there more listboxitems there space in listbox. following xaml code makes vertical scrollbar visible. however, remains disabled:
<listbox name="li1standortlinks" background="transparent" maxheight="300" scrollviewer.verticalscrollbarvisibility="visible"> <wrappanel name="wp1standortlinks" itemheight="80" itemwidth="150" width="755" /> </listbox>
how functional vertical scrollbar when needed?
problem two
when clicking listbox not @ listboxitem [for example, in between 2 of them], background of whole listbox gets highlighted in blue. background transparent , should remain if listbox clicked. catching click-event , setting background transparent seems not help. blue highlight-color disappear, instead of listbox background going transparent, remains grey. can change style color not change @ when clicking @ listbox? never changed styles in wpf, though, i'd need precise explaination.
this may work problem 1 :
<listbox name="li1standortlinks" background="transparent" maxheight="300" scrollviewer.verticalscrollbarvisibility="visible"> <listbox.itemspanel> <itemspaneltemplate> <wrappanel isitemshost="true" orientation="horizontal" /> </itemspaneltemplate> </listbox.itemspanel> </listbox>
for problem 2 : may work (change style listbox)
<listbox name="li1standortlinks" background="transparent" maxheight="300" scrollviewer.verticalscrollbarvisibility="visible"> <listbox.style> <style targettype="listbox"> <style.resources> <!-- background of selected item when focussed --> <solidcolorbrush x:key="{x:static systemcolors.highlightbrushkey}" color="transparent" /> <!-- background of selected item when not focussed --> <solidcolorbrush x:key="{x:static systemcolors.controlbrushkey}" color="transparent" /> <solidcolorbrush x:key="{x:static systemcolors.highlighttextbrushkey}" color="black" /> </style.resources> </style> </listbox.style> </listbox>
Comments
Post a Comment