gridviewcolumn - WPF GridViewColumnHeader disable the dragging of columns between unmovable columns -
gridviewcolumn - WPF GridViewColumnHeader disable the dragging of columns between unmovable columns -
i have listview view of gridview i.e.:
<listview> <listview.view> <gridview /> </listview.view> </listview>
with example:
the 2 columns reddish text have style applied ishittestvisible property set false - prevents user moving 2 columns.
it possible, , should be, user drag other 3 columns amongst themselves.
unfortunately, scenario, user can move 1 of 3 moveable columns before either first or sec unmovable columns, moving column should not movable, here:
my aim maintain unmovable columns whilst allowing movable columns moved amongst themselves.
the amount of unmovable columns variable, possible gridview has no fixed columns whatsoever, possible however, there may 2 - shown here - or more (for larger tables).
the question hence be, how can hinder user moving columns before column cannot moved?
thank time!
after finding post @rida:
how disable moving/reordering of listview header in wpf?
i decided solve problem dependencyproperty called fixedcolumns , integer.
public class columnsextension : dependencyobject { public static readonly dependencyproperty fixedcolumnsproperty = dependencyproperty.registerattached("fixedcolumns", typeof(int), typeof(columnsextension), new propertymetadata(0)); public static int getfixedcolumns(dependencyobject obj) { homecoming (int)obj.getvalue(fixedcolumnsproperty); } public static void setfixedcolumns(dependencyobject obj, int value) { obj.setvalue(fixedcolumnsproperty, value); } }
i parse text file containing info describes columns, if encounter column position fixed, increment number of fixed columns:
foreach (var parsedcolumn in parsedcolumns) { var fcols = this.testlv.getvalue(columnsextension.fixedcolumnsproperty); // increment number of fixed columns if (parsedcolumn.columnresize == columnresize.isfixed) this.testlv.setvalue(columnsextension.fixedcolumnsproperty, (int)fcols + 1); // ... }
once parsing has finished, subscribe collectionchanged eventhandler , code @rida proposed instead of checking 0, check see if newstartingindex smaller number of fixed columns.
if case, cancel move.
the result can have constellation 2 fixed columns:
where possible me drag lastly 3 columns between themselves, not before fixed column.
please note drag adorner still visible when attempting drag column before fixed column drop fails main thing me. time may seek , alter drop adorner situation.
i hope helps along way, code @rida helped me.
wpf gridviewcolumn
Comments
Post a Comment