c# - WPF DataGrid Cell binding by data from Parent control -



c# - WPF DataGrid Cell binding by data from Parent control -

i trying sort out , cannot see lite in dark.

i have worksheets (tables) in workspace. dynamic (columns, mount of tables, ...). based on object worksheet set datagrid rotation.

vm structure:

controlvm : { workspace: [ { worksheet: [ { dataviewbindingdata: [dataview type], isrotated: rue | false }, {...} ] } <scrollviewer grid.column="0" grid.row="0" > <itemscontrol itemssource="{binding path=workspace}" > <itemscontrol.itemtemplate> <datatemplate> <stackpanel> <expander header="{binding path=worksheetname}" expanddirection="down" isexpanded="true" > <stackpanel> <datagrid canuserresizecolumns="false" headersvisibility="column" canusersortcolumns="false" horizontalalignment="stretch" canuseraddrows="false" margin="5" selectionunit="cell" selectionmode="single" itemssource="{binding path=dataviewbindingdata}" loaded="datagrid_loaded" beginningedit="datagrid_beginningedit" /> </stackpanel> </expander> </stackpanel> </datatemplate> </itemscontrol.itemtemplate> </itemscontrol> </scrollviewer>

and within custom styles resources in base of operations style command (header, cells), trying access isrotated property of worksheet object

<style x:key="datagridbase" targettype="control"> <style.triggers> <!-- todo cannot find ancestor info binding --> <datatrigger binding="{binding isrotated, converter={staticresource debugconverter}, mode=oneway}" value="true"> <setter property="layouttransform"> <setter.value> <transformgroup> <rotatetransform angle="-90" /> <scaletransform scalex="-1" scaley="1" /> </transformgroup> </setter.value> </setter> <setter property="textoptions.textformattingmode" value="display" /> </datatrigger> </style.triggers> </style > <!--datagrid cells--> <style targettype="{x:type datagridcell}" basedon="{staticresource datagridbase}" />

and thats problem, dont know how access parent control's info bind property. suggestions.

the implicit datacontext within datagridcell current datagridrow's bound item. in case have utilize relativesource find datagrid , set path datacontext.isrotated (the datagrid's datacontext worksheet):

<datatrigger binding="{binding datacontext.isrotated, relativesource={relativesource ancestortype=datagrid} converter={staticresource debugconverter}, mode=oneway}" value="true"> <!-- ... -->

c# wpf binding datagrid

Comments

Popular posts from this blog

assembly - What is the addressing mode for ld, add, and rjmp instructions? -

vowpalwabbit - Interpreting Vowpal Wabbit results: Why are some lines appended by "h"? -

Is there a way to convert an HTML page styled with Bootstrap CSS into email-compatible html? -