This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
how can I set the column width to a double value with star notation .. it does not take gridlength as assumed I need to do this in code behind .. it works of course in xaml .. but I am not using xaml for the majority of my application all is pretty much generic and defined on the meta level Another problem: Dragging an empty column header creates a null object exception. thanks gmd |
|
|
Hello gmd The Width property is type double because the star-sizing and auto-sizing features were added in a nightly build rather than a major version. For now it is a little inconvenient to set this in code behind, but still possible. You can create an instance of the DataGridColumnWidthConverter and use the ConvertFrom method to pass in the string that you would normally use in xaml. Here is an example:
I was unable to reproduce the null reference exception with dragging an empty column header. Could you please describe what needs to be done to reproduce this. Jason Fasuchelle |
|
|
Thanks Jason.. the null reference happens when you attempt to drag the small column header which is created for the row headers. just make a drag attempt and let go again at the same place ... The row marked with ** is where it happens in OnGiveFeedback
I am also experiencing another problem since I moved to creating the columns in code behind: I lost the sort. I set PropertyName and sort direction but the column won't sort ... I will try next with sortcomparer but it should not be necessary at least for some of my columns, nevertheless I will try it regards gmd UPDATE: |
|
|
Hello gmd The issue caused by dragging the empty column header will be resolved in the next nightly build. For the sorting, try set the SortDirection property after the DataGrid has loaded. Jason Fauchelle |
|
|
Jason, I tried that already .. it is in the code since ages .. and the comment tells it this is the code for creating the view with a datagrid
and the sort routine being called above is from one of your samples
and to be complete .. this is the code which creates the columns
this all works fine when I have a sortcomparer .. in case there is non for a plain column with one textfield it does not work .. I think it has to do with the display template here is an example of one simple template
any ideas ? regards gmd |
|
|
Hello gmd Unless I am mistaken, it looks like you are setting the SortDirection of all columns to Ascending when you create the columns. Keep in mind that the DataGrid currently only supports sorting 1 column at a time. Also, when the Sort function is called, it will be ineffective since the column SortDirection is already Ascending, so the property will not change. What happens if you don't set the SortDirection in the loop that creates the columns? Jason Fauchelle |
|
|
I must have misunderstood the property SortOrder .. anyway .. I removed the line where I set the SortOrder on each column and only the initial sort is called. I made sure that the SortOrder was None before the Sort method was called once. I tried both Ascending and Descending and neither the initial sort nor the click on the headers works .. nothing happens .. When I load the SortComparer the grid sorts when I click on the headers. I have a generic SortComparer which only needs the property name and will work so for my generic routine it does not really matter because I set the SortComparer dynamically, however this was not intended that way by you ... regards gmd |
|
|
Odd that it does not work by just using the PropertyName. I have not been able to reproduce this issue, so if you want, you could send a repro project so we can find out what scenario is causing the sort to not respond. If however you are fine with using the custom sort comparer, then don't worry about it. Jason Fauchelle |
|
|
I keep this on the list and when I find the time to isolate a small part I will do it .. for now I use the SortComparer regards gmd |
|