i facing problem setting following xaml layout:
rowheightauto.xaml
<window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" x:class="gridmaxheight.rowheightauto" title="rowheightauto" windowstate="maximized"> <grid> <grid.rowdefinitions> <rowdefinition /> <rowdefinition height="auto" maxheight="200" /> </grid.rowdefinitions> <stackpanel background="lightgray" grid.row="0"></stackpanel> <datagrid name="datagrid1" grid.row="1" /> </grid> the datagrid1 control isnt showing scrollbars lot of columns , rows defined. works find when replace height="auto" height="*" horizontal , vertical scrollbars appear expected.
also works when declare maxheight directly @ datagrid1, thats not want want.
is bug childcontrol ignores maxheight on setting height="auto" or propably making wrong? same behaviour can reproduced listbox/listview , on, third party controls componentone, telerik...
if bug - know workaround or have other hints me?
here code how set itemssource of datagrid. rowheightauto.xaml.cs
public partial class rowheightauto : window { private readonly datetime _start; public rowheightauto() { initializecomponent(); datagrid1.itemssource = gettestdata(); _start = datetime.now; dispatcher.begininvoke(new action(() => messagebox.show((datetime.now - _start).totalseconds.tostring(cultureinfo.invariantculture))), dispatcherpriority.contextidle, null); } public static list<testdata> gettestdata() { const int maxcols = 501; const int maxrows = 300; var testdatas = new list<testdata>(maxrows); (int = 0; < maxrows; i++) testdatas.add(new testdata()); (int = 0; < maxcols; i++) { string propname = string.format("property{0}", addleadingzeros(i)); (int j = 0; j < maxrows; j++) testdatas[j][propname] = propname; } return testdatas; } private static string addleadingzeros(int val) { return val.tostring(cultureinfo.invariantculture).padleft(3, '0'); } } public class testdata { public object this[string propertyname] { { var mytype = gettype(); var mypropinfo = mytype.getproperty(propertyname); return mypropinfo.getvalue(this); } set { var mytype = gettype(); var mypropinfo = mytype.getproperty(propertyname); mypropinfo.setvalue(this, value, null); } } public string property000 { get; set; } public string property001 { get; set; } public string property002 { get; set; } public string property003 { get; set; } ... public string property498 { get; set; } public string property499 { get; set; } public string property500 { get; set; } } since first post, hope did correct. :) in advance.
this is.
the reason why not see scrollbar's because though grid clip's datagrid, it's merely clip, actualheight of datagrid height if allowed show it's children. not seeing it's scrollbar's. actualheight cos it's allowed space wants height="auto" on grid. the reason wouldn't call bug cos might desire behavior if want play thinking this, think i'd call bug in terms of "not desirable functionality" "incorrect output"cliptobounds property of grid animations , behavior desire.
to behavior looking for,
- apply
maxheightondatagridor use gridrowdefinition.height="*"<- both mentioned (not sure why not want do?) - or use
relativesourcebindingondatagrid
something -
<datagrid name="datagrid1" grid.row="1" height="{binding relativesource={relativesource findancestor, ancestortype={x:type grid}}, path=rowdefinitions[1].actualheight}"> for such issues snoop friend. can check behavior , realize why scrollbar's aren't shown when check actualheight on datagrid using snoop , see allocates quite bit more height child control.
Comments
Post a Comment