c# - Synchronize row heights in custom wpf datagrid -
c# - Synchronize row heights in custom wpf datagrid -
i want visually represent info in columns, rather row representation of datagrid. think of info list<column>
column contains list<cell>
. reason not transpose info , utilize datagrid want have ability add/remove columns dynamically, without having process of data.
+--------------------------------------------+ | | col header | col header | ... | | row header | cell | cell | ... | | ... | ... | ... | ... | +--------------------------------------------+
i have sample of xaml pretty much want:
<stackpanel orientation="horizontal"> <stackpanel orientation="vertical" verticalalignment="top"> <textbox text="" isreadonly="true" borderthickness="0" horizontalalignment="stretch"/> <textbox text="" isreadonly="true" borderthickness="0,0,0,2" borderbrush="black" horizontalalignment="stretch"/> <itemscontrol itemssource="{binding rowheaders}"> <itemscontrol.itemspanel> <itemspaneltemplate> <stackpanel orientation="vertical"/> </itemspaneltemplate> </itemscontrol.itemspanel> <itemscontrol.itemtemplate> <datatemplate> <textbox text="{binding mode=oneway}" isreadonly="true" borderthickness="0,0,2,2" borderbrush="black" fontweight="bold" /> </datatemplate> </itemscontrol.itemtemplate> </itemscontrol> </stackpanel> <itemscontrol itemssource="{binding columns}"> <itemscontrol.itemspanel> <itemspaneltemplate> <stackpanel orientation="horizontal" /> </itemspaneltemplate> </itemscontrol.itemspanel> <itemscontrol.itemtemplate> <datatemplate> <stackpanel orientation="vertical" > <textbox text="{binding colhead1, mode=oneway}" isreadonly="true" borderthickness="0" fontweight="bold" horizontalalignment="stretch"/> <textbox text="{binding colhead2, mode=oneway}" isreadonly="true" fontweight="bold" borderthickness="0,0,0,2" borderbrush="black" horizontalalignment="stretch"/> <itemscontrol itemssource="{binding cells}"> <itemscontrol.itemspanel> <itemspaneltemplate> <stackpanel orientation="vertical" /> </itemspaneltemplate> </itemscontrol.itemspanel> <itemscontrol.itemtemplate> <datatemplate> <textbox x:name="textbox" text="{binding}" isreadonly="{binding isreadonly}" borderthickness="0,0,0,2" borderbrush="black" horizontalalignment="stretch"/> </datatemplate> </itemscontrol.itemtemplate> </itemscontrol> </stackpanel> </datatemplate> </itemscontrol.itemtemplate> </itemscontrol> </stackpanel>
however, how can ensure rows aligned? cells within column guaranteed aligned since contained within single itemscontrol. however, each column within own stackpanel. there way ensure rows aligned?
also, seem solution problem or there improve alternative?
you should able utilize grid.issharedsizescope create rows share size.
i've used in past making unassociated columns same size, , there's no reason can't used rows well
c# wpf
Comments
Post a Comment