c# - ListView returning exception on load -


i have listview want format several fields populating object. created data template threw invalidoperationexception blank page , no indication of cause of exception. found article on codeproject , have datatemplate embedded in setter definition:

<usercontrol x:class="servpro.framework.viewermodule.views.menuview"          xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"          xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"          xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"           xmlns:d="http://schemas.microsoft.com/expression/blend/2008"           mc:ignorable="d"           d:designheight="580" d:designwidth="210"> <usercontrol.resources>     <style targettype="listview">         <setter property="itemtemplate">             <setter.value>                 <datatemplate>                     <stackpanel orientation="vertical">                         <textblock                              background="transparent"                             foreground="black"                              fontsize="12"                              text="{binding path=currentevent.eventtypename, mode=oneway}" />                         <textblock                              background="transparent"                             foreground="black"                              fontsize="12"                              text="{binding path=currentevent.eventmessage, mode=oneway}" />                         <stackpanel orientation="horizontal">                             <textblock                                  background="transparent"                                  foreground="black"                                  fontsize="8"                                  text="{binding path=currentevent.eventloggedon, mode=oneway}"                                 margin="0,0,10,0" />                             <textblock                                 background="transparent"                                  foreground="black"                                  fontsize="8"                                 text="{binding path=currentevent.program, mode=oneway}" />                             <textblock                                  background="transparent"                                  foreground="black"                                  fontsize="8"                                 text=":" />                             <textblock                                  background="transparent"                                  foreground="black"                                  fontsize="8"                                  text="{binding path=currentevent.method, mode=oneway}" />                         </stackpanel>                     </stackpanel>                 </datatemplate>             </setter.value>         </setter>     </style> </usercontrol.resources> <grid margin="4">     <listview          itemssource="{binding path=eventlist, mode=oneway}"          height="568" verticalalignment="top"          width="201" horizontalalignment="left"          margin="4" >         <border cornerradius="11" />         <listview.borderbrush >             <solidcolorbrush color="#99ffffff" opacity="0" />         </listview.borderbrush>         <listview.background>             <solidcolorbrush color="#99ffffff" opacity="0"/>         </listview.background>     </listview> </grid> 

with definition asis runtime exception , pointing @ xaml. still not understand why i'm getting it. exception:

'add value collection of type 'system.windows.controls.itemcollection' threw exception.' line number '55' , line position '13'.

it has inner exception:

{"operation not valid while itemssource in use. access , modify elements itemscontrol.itemssource instead."}

i'm using itemssource why getting exception??

it turned out setting of border , background brushes in main line of xaml issue. removed them , use setter.property in datatemplate , application runs now.

so future designs: when defining of listview data template, important styling remain data template. final page design ended different added formatting following this blog


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -