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
|
HI Can somebody help me. i want to do something like this with WpfElement Datagrid
Is it possible to do that with wpfelement datagrid??. Thanks in advance |
|
|
Hello Alveen Yes this is possible. The cells of the DataGrid have 2 modes: display mode and edit mode. What you'll want to do is provide a custom display template for each column that you want to apply this look. Below is an example of the code you would use inside a DataGridColumn that you've set up in the xaml.
This is just a TextBlock where the text is binding to the appropriate property on your model objects for that column. The TextTrimming property is how you display the elipsis. To display the ToolTip you can set the ToolTip property to also bind to your model object. WPF does not automatically disable the ToolTip is the elipsis is not displayed. But there are ways you can implement this: http://tranxcoder.wordpress.com/2008/10/09/showing-tooltips-on-a-trimmed-textblock-wpf/ Let me know if you need help setting the display template. -Jason Fauchelle |
|
|
Thanks Jason . Your code work well using TextTrimming, but i need help to display template. Here is my code
And
I have yhis error Member 2 "IsTextTrimmed" is not recognized or is not accessible Thank you in advance |
|
|
Hello Alveen The IsTextTrimmed property comes from a custom control that they made in a previous blog post. Here are 2 blog posts from them that can help you implement this for your application. The first post uses reflection to get some private fields that can be used to calculate if the text is trimmed. The second post is probably a better approach which statically does some estimate calculations instead of using reflection, and then puts the result in an attached property (IsTextTrimmed) on the TextBlock which can be bound to. http://tranxcoder.wordpress.com/2008/10/09/customizing-lookful-wpf-controls/ http://tranxcoder.wordpress.com/2008/10/12/customizing-lookful-wpf-controls-take-2/ -Jason Fauchelle |
|
|
Hello Jason , I have two issues while apply DataGridColumn.DisplayTemplate for TextTrimming . Attached is sample project. Thanks, Yap |
|
|
Hello Yap Thanks for the repro project. Both these issues can be resolved with the same fix. All you need to do is set the PropertyName property of the DataGridColumn to "Surname". The model functionalities of features like grouping and filtering need to be told what property they are dealing with. The display template is unfortunately not enough because this is purely a visual component that is difficult for the model to interpret. So telling the column what property to group/filer via the PropertyName is the way to fix this. I've made a note to see if we can improve the discoverability of this for this scenario in a future version, as well as avoid the null reference exception. -Jason Fauchelle |
|
|
Hello Jason, Thanks you . |
|