wpf - Bind to property in a relative source sends me up to the mainwindow + Catel -
have following xaml code
<catel:usercontrol x:class="sicuap.views.catproducto_categoriasview" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:catel="http://catel.codeplex.com" xmlns:controls="clr-namespace:mahapps.metro.controls;assembly=mahapps.metro" xmlns:views="clr-namespace:sicuap.views"> <!-- resources --> <usercontrol.resources> </usercontrol.resources> <!-- content --> <catel:stackgrid> <catel:stackgrid.rowdefinitions> <rowdefinition height="auto"></rowdefinition> <rowdefinition height="auto" /> <rowdefinition height="auto" /> <rowdefinition height="auto" /> </catel:stackgrid.rowdefinitions> <views:cmdglobalesbdview></views:cmdglobalesbdview> <label content="catalogo de categorias de producto" style="{staticresource estilotitulocontrol}"> </label> <datagrid margin="0 10 0 0" maxheight="200" itemssource="{binding producto_categorias}" selecteditem="{binding selectedproducto_categoria}" autogeneratecolumns="false" scrollviewer.verticalscrollbarvisibility="auto" canuseraddrows="false" canuserresizecolumns="false" alternatingrowbackground="#d2edf7"> <datagrid.columns> <datagridtemplatecolumn header="clave" minwidth="100"> <datagridtemplatecolumn.celltemplate> <datatemplate> <stackpanel> <textblock text="{binding id_categoria}"></textblock> </stackpanel> </datatemplate> </datagridtemplatecolumn.celltemplate> </datagridtemplatecolumn> <datagridtemplatecolumn header="nombre" minwidth="200"> <datagridtemplatecolumn.celltemplate> <datatemplate> <stackpanel> <textblock text="{binding nombre}"></textblock> </stackpanel> </datatemplate> </datagridtemplatecolumn.celltemplate> </datagridtemplatecolumn> <datagridtemplatecolumn header="descripcion" minwidth="300"> <datagridtemplatecolumn.celltemplate> <datatemplate> <stackpanel> <textblock text="{binding descr}" horizontalalignment="stretch"></textblock> </stackpanel> </datatemplate> </datagridtemplatecolumn.celltemplate> </datagridtemplatecolumn> </datagrid.columns> <datagrid.cellstyle> <style targettype="{x:type datagridcell}"> <style.triggers> <trigger property="datagridcell.isselected" value="true"> <setter property="foreground" value="black" /> </trigger> </style.triggers> </style> </datagrid.cellstyle> </datagrid> <views:dataproducto_categoriasview datacontext="{binding selectedproducto_categoria}" visibility="{binding relativesource= {relativesource mode=findancestor, ancestortype={x:type usercontrol}},path=datacontext.vistadetalleesvisible, converter={staticresource booleantovisibilityconverter}}" /> </catel:stackgrid> </catel:usercontrol>
when try bind visibility property of internal view
<views:dataproducto_categoriasview datacontext="{binding selectedproducto_categoria}" visibility="{binding relativesource= {relativesource mode=findancestor, ancestortype={x:type usercontrol}},path=datacontext.vistadetalleesvisible, converter={staticresource booleantovisibilityconverter}}" />
to parent sends me way datacontext of main window.
the parent loaded in contentcontrol inside main window.
why cant bind datacontext of parent user control?
it's same question this one.
read docs, article usercontrol - under hood.
Comments
Post a Comment