c# - Background in TreeViewItem not full width -


i new wpf forms , ran across issue when trying set background in treeviewitem.

<window x:class="wpf_test.mainwindow"         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"         title="mainwindow" height="350" width="525">     <window.resources>         <!--styles-->         <style x:key="guientity" targettype="{x:type control}">             <setter property="minwidth" value="150" />             <setter property="maxwidth" value="150" />         </style>         <style targettype="treeviewitem">             <setter property="isexpanded" value="true" />         </style>         <!--data sources-->         <x:array x:key="booleanlistdata" type="sys:string" xmlns:sys="clr-namespace:system;assembly=mscorlib">             <sys:string>true</sys:string>             <sys:string>false</sys:string>         </x:array>     </window.resources>     <grid>         <treeview name="treeview1" margin="5" background="azure">             <treeviewitem header="complextypeproperty" margin="5">                 <checkbox style="{staticresource guientity}" margin="3,3,10,3" content="instance" />                 <stackpanel orientation="horizontal" background="lightgray">                     <label margin="0,2,0,0" content="isboolproperty" width="150" />                     <combobox margin="5" style="{staticresource guientity}" itemssource="{staticresource booleanlistdata}" />                 </stackpanel>             </treeviewitem>         </treeview>     </grid> </window> 

the problem background being set in stackpanel doesn't go full width (to right) of treeview control. tried adding horizontalallignment="stretch" controls treeview down had no effect. width of background on stackpanel goes end of combobox.

by setting background on treeview confirmed did take full width of form wouldn't issue.

does know how extend background end of treeview's size?

how go overriding grid in simplest way?

here blog post covers problem , gives solution. far remember, worked ok me. need retemplate treeviewitem. lot of xaml think proper solution

https://leecampbell.com/2009/01/14/horizontal-stretch-on-treeviewitems/


Comments

Popular posts from this blog

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -