c# - Binding in ItemsControl not bubbling to the item from ItemsSource -


here code have in xaml:

        <!-- itemscontrol print gdts on map overlay on tiles -->         <itemscontrol itemssource="{binding gdts, mode=oneway}" grid.columnspan="3" grid.rowspan="3" panel.zindex="7">           <itemscontrol.itemspanel>             <itemspaneltemplate>               <canvas cliptobounds="true" snapstodevicepixels="true"/>             </itemspaneltemplate>           </itemscontrol.itemspanel>           <itemscontrol.itemcontainerstyle>             <style targettype="contentpresenter">               <setter property="canvas.left"  value="{binding distancetoleft}"/>               <setter property="canvas.top"   value="{binding distancetotop}"/>               <setter property="contenttemplate">                 <setter.value>                   <datatemplate>                     <grid>                       <usercontrols:commindicator commconfig="edt" dtantennamode="edirectional" dtazimuth="{binding yaw}"/>                       <image horizontalalignment="center" verticalalignment="center" source="{binding sourcepath}" width="{binding width}"/>                       <rectangle height="{binding height}" width="{binding width}" stroke="orange" strokethickness="2"/>                       <ellipse height="4" width="4" fill="orange" horizontalalignment="center" verticalalignment="center"/>                     </grid>                   </datatemplate>                 </setter.value>               </setter>             </style>           </itemscontrol.itemcontainerstyle>         </itemscontrol> 

all bindings in there working except 1 added within usercontrol (commindicator) : dtazimuth="{binding yaw}".

the error see in snoop on binding 1 : "system.windows.data error: 40 : bindingexpression path error: 'yaw' property not found on 'object' ''commindicator' (name='')'. bindingexpression:path=yaw; dataitem='commindicator' (name=''); target element 'commindicator' (name=''); target property 'dtazimuth' (type 'int32')"

is there way force th binding check in itemscontrol "currentitem" ?

edit 1: here xaml usercontrol :

    <usercontrol x:class="usercontrols.commindicator"              xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"              xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"              xmlns:ed="http://schemas.microsoft.com/expression/2010/drawing"              xmlns:usercontrols="clr-namespace:usercontrols"              datacontext="{binding relativesource={relativesource self}}"              snapstodevicepixels="true">    <usercontrol.resources>     <resourcedictionary>       <usercontrols:commconfigtovisibility x:key="commconfigtovisibility"/>       <usercontrols:antennamodetoangle     x:key="antennamodetoangle"/>       <usercontrols:antennamodetocolor     x:key="antennamodetocolor"/>     </resourcedictionary>   </usercontrol.resources>    <grid width="100" height="100">         <!-- use design reference -->         <!--<grid width="70" height="70" horizontalalignment="center" verticalalignment="center">           <ellipse width="66" height="66" stroke="whitesmoke" strokethickness="3" horizontalalignment="center" verticalalignment="center"/>           <ellipse width="66" height="66" fill="whitesmoke" strokethickness="3" horizontalalignment="center" verticalalignment="center" opacity="0.30"/>           <ellipse width="70" height="70" stroke="limegreen" strokethickness="3" horizontalalignment="center" verticalalignment="center"/>           <image horizontalalignment="center" verticalalignment="center" source="/resources/blackshadowtopview.png" width="40"/>           <textblock text="160" margin="6" horizontalalignment="center" textalignment="center" foreground="black"/>         </grid>-->          <!-- adr communication circle indicator -->          <grid horizontalalignment="center" verticalalignment="center" width="100" height="100"               visibility="{binding commconfig, converter={staticresource commconfigtovisibility}, converterparameter={x:static usercontrols:commtype.edatarelay}}">           <ellipse width="100" height="100" stroke="black" strokethickness="7"/>           <ed:arc width="99" height="99" fill="slategray" startangle="0" endangle="360" arcthickness="5"/>           <ed:arc width="99" height="99" stretch="none" arcthickness="6"                 fill="{binding drantennamode, converter={staticresource antennamodetocolor}}"                 startangle="{binding drantennamode, converter={staticresource antennamodetoangle}, converterparameter={x:static usercontrols:angletype.estartangle}}"                  endangle="{binding drantennamode, converter={staticresource antennamodetoangle}, converterparameter={x:static usercontrols:angletype.eendangle}}"/>            <grid.layouttransform>             <rotatetransform angle="{binding drazimuth}"/>           </grid.layouttransform>         </grid>          <!-- adt/gdt communication circle indicator -->         <grid horizontalalignment="center" verticalalignment="center" width="90" height="90"               visibility="{binding commconfig, converter={staticresource commconfigtovisibility}, converterparameter={x:static usercontrols:commtype.edatatransmitter}}">           <ellipse width="88" height="88" stroke="black" strokethickness="7"/>           <ed:arc width="87" height="87" fill="slategray" startangle="0" endangle="360" arcthickness="5"/>           <ed:arc width="87" height="87" stretch="none" arcthickness="6"                 fill="{binding dtantennamode, converter={staticresource antennamodetocolor}}"                 startangle="{binding dtantennamode, converter={staticresource antennamodetoangle}, converterparameter={x:static usercontrols:angletype.estartangle}}"                  endangle="{binding dtantennamode, converter={staticresource antennamodetoangle}, converterparameter={x:static usercontrols:angletype.eendangle}}"/>            <grid.layouttransform>             <rotatetransform angle="{binding dtazimuth}"/>           </grid.layouttransform>         </grid>       </grid>     </usercontrol> 

remove this:

datacontext="{binding relativesource={relativesource self}}" 

from usercontrol, , add this:

<usercontrol ...              x:name="view"> 

and change bindings inside usecontrol use elementname, this:

{binding elementname=view, path=dtantennamode, converter={staticresource antennamodetocolor}}"

also, there seem lot of converters going on there. suggest change use controltemplate , inside can put controltemplate.triggers , remove need converters , datacontext hacks.


Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -