Hello,
I need to enable automatic sizing to content for xamDataGrid columns (fields) till some limit. I set Width="Auto" in FieldSettings and it does resize automatically but I can't find proper way to introduce the limit to stop the automatic resize. I want to allow the user to resize the columns manually without limitations, so setting CellMaxWidth or LabelMaxWidth in FieldSettings is not an option for me. Are there any built in options or recommended approaches for that?
Thanks in advance.
Hello Vital,
There are no built in options that you can enable that would allow this. If you set the CellMaxWidth or the LabelMaxWidth then it will restrict both mouse and content resizing. You'd have to restrict the width manually, maybe by handling the LabelPresenter's SizeChanged event and then checking to see if the new size is caused by the mouse or the content. If it is caused by the content then you can check to see if it passed a certain point. Passed this point you would restrict the width of the field.
In order to determine if the column was resized by mouse or not you can use the Mouse.LeftButton static property. http://msdn.microsoft.com/en-us/library/system.windows.input.mouse.leftbutton(v=vs.110).aspx
I haven't tested this myself just yet, I'm just throwing out an idea that may work. I'm working on a sample to see if this will work for your needs.
Hi Vital,
Just a quick update. The method I proposed above isn't going to work too well. Since columns are not resized in real-time (there's a ghost splitter that appears to show you where the column will end up), checking to see if the mouse is down when the resize event occurs won't provide us with any information. I'll see if there is another way to do this.
I've investigated your requirement and currently there is no way to implement this such that you can resize the column with the mouse but still have the content automatically resize the column up to a certain amount. The grid is setup in such a way that once you manually set the column's size with the mouse, the column is forced to use the width specified by the user. So after this point, the grid will not resize the column based on content.
After working on this and doing some research, this has been determined to be a new product idea. You can suggest new product ideas for future versions (or vote for existing ones) at <http://ideas.infragistics.com>.
There are many benefits to submitting an product idea:
- Direct communication with our product management team regarding your product idea.
- Notifications whenever new information regarding your idea becomes available.
- Ability to vote on your favorite product ideas to let us know which ones are the most important to you. You will have ten votes for this and can change which ideas you are voting for at any time.
- Allow you to shape the future of our products by requesting new controls and products altogether.
- You and other developers can discuss existing product ideas with members of our Product Management team.
Steps to create your idea:
1. Log into the Infragistics Product Idea site at http://ideas.infragistics.com (creating a new login if needed).
2. Navigate to the product / platform channel of your choice (e.g. WPF, Windows Forms, ASP.NET, HTML5 / Ignite UI, iOS / NucliOS, etc.)
3. Add your product idea and be sure to be specific and provide as much detail as possible. Explain the context in which a feature would be used, why it is needed, why it can’t be accomplished today, and who would benefit from it. You can even add screenshots to build a stronger case. Remember that for your suggestion to be successful, you need other members of the community to vote for it. Be convincing!
The Product Idea site puts you in the driver’s seat and allows you to track the progress of your ideas at any time, see how many votes it got, read comments from other developers in the community, and see if someone from the product team has additional questions for you.
Let me know if you have any further questions on this matter.