-
Notifications
You must be signed in to change notification settings - Fork 683
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Proposal: Simplify Grid Column and Row Definitions #673
Comments
Might I suggest there be consideration for the ability to add a name or key to columns, do you can declare it in XAML.
|
@mdtauk that's part of the bigger issue I link to. This issue was specifically for a small subset that doesn't add any new feature but just simplifies the xaml |
You mention string conversion, so I thought adding a string value for a name could translate to an int value assigned Inthe definition lists? |
But named columns is adding an entirely new feature. I purposely tried to keep this suggestion without adding new features. |
Yeah, it'd be great if we could add this exact same shortcut to both UWP Grid and WPF Grid. |
Great idea, love it! |
This looks great! I have a small issue with that syntax though, I feel like the |
@dotMorten This would probably be a good addition to Xamarin Forms if it hasn't been proposed already. Maybe after it's discussed well here first. |
This is great and exactly what som people have done in custom controls, so it feels familiar. Any ideas how to handle Max/Min Width/Height. |
Ah shucks. Didn't think about that. One simple solution is just to state you don't get that fine grained control with the simple syntax (in order to keep the syntax simple and focus on covering the most common scenarios). |
We should avoid introducing a simpler syntax that would eventually be replaced by the more robust and powerful new syntax and functionality. So whatever is decided about this simple width/height syntax, it needs to keep in mind what comes next |
This is inconsistent with other shortcuts (such as margin, or padding) where commas (or spaces) are between values, not after them. |
@mrlacey wait, I think you misquoted my message 🤔 What I suggested (just as an idea, not necessary the best possible syntax) was to use EDIT: I mean, in the first post of this proposal you can actually read |
@Sergio0694 my mistake. you are correct. |
I don't think you should be able to add empty rows, so each entry would need at least a *, so having a collection of commas without values would be invalid |
@mdtauk Precisely what I was suggesting 😄 |
Some inspiration from CSS Grid would be great here (though possibly throw the scope out)
|
The equivalent XAML was just above it |
@dotMorten First of all, I really like this issue, as it's a quick win! Great idea to extract this from the bigger issue.
Yes, but the equivalent XAML for ,, are two 1* RowDefinitions. So, I think - like @mrlacey and @Sergio0694 mentioned - we shouldn't have empty values in the new short-hand syntax, as you should be able to use that syntax also without commas, but spaces instead (like you can for example for Margin). These should be possible options:
But not empty values like here, as it doesn't allow the space-instead-of-comma-syntax:
|
I Love it! 👍 |
Very nice idea! |
Good idea! The same could be done for cell positions. Instead of
one could write
(I assume that the ranges are inclusive here, but I may be overruled as I was with System.Range) This would also not be a new feature, but only a simpler syntax. I do realize that |
@MichaelRumpler interesting idea but it again goes against the premise of this issue by introducing a new API (Grid.Set/GetCell and not sure what the type would be?) and this introducing more red tape to get it through. Issue #51 is where the more advanced stuff is discussed. |
I like it! It would be nice to still support databinding with this syntax:
|
@wbokkers I don't think that's possible with a string converter. I think the idea of keeping it simple for the 80% use case, and use full syntax when you need more fine-grained control is the best/simplest/most-achievable way to go. Trying to solve all possible suggestions will just lead to a complicated design with a million devilled details that we'd never be able to push through. |
Also @MichaelRumpler - you probably already know this, but just in case, if you really want to use that |
Yes, I 100% agree with @dotMorten and @Sergio0694. @MichaelRumpler I like that syntax, but it would mean we have to add another attached property that gives you exactly the same behavior that we have already with the existing properties. So, it's pretty much a "proxy property". I think what @Sergio0694 said is good, using an attached property that doesn't necessarily have to be in the Grid class works for this. @wbokkers I think that's a really hard one. x:Bind generates code at compile-time, the string is converted at runtime. In addition, the markup extension is only half of the attribute value. I've never seen something like that. While it could make sense, I think it's a very complicated thing to implement. And I can't remember many cases where I needed a data binding for the sizes of RowDefs/ColDefs, so I'd say, let's keep it simple, and if a dev needs a data binding, they could still go with the normal object element syntax. So, let's keep this issue simple, so that we can get it through. I think this was also the idea why @dotMorten created this separate issue, because it's a quick win that is not too hard to implement. If I see it correctly, @Sergio0694, @mrlacey, @mdtauk, and I agreed that we don't want empty values between the commas, and no one else said empty values should be supported (Except the initial proposal from @dotMorten ). So, @dotMorten, the rest of this comment is for you. :-) What do you think with adjusting the initial proposal with the possible syntax options I wrote in my previous comment? And getting rid of this:
And add this:
And add here additional, and write that you might want to do this for better readability. Ignoring the spaces doesn't give you a better readability, you add them to get a better readability, and the string converter ignores them (The additional spaces, as you should be able to split the values also by spaces):
And maybe write explicitly that min/max values are not supported. Then we can have another issue once this is implemented. |
You're right in not wanting to overcomplicate things. I use databinding here in maybe 0.01% of the grids I use. |
I can confirm this is still a problem in Visual Studio 22 (17.0.4) It does not affect the app itself, but still gives an error and stops hot reload. |
Should be fixable by updating the tooling on WASDK's end to understand how to instantiate collections from strings the same way this feature did for markup loaded normally. But that is more of a feature-level request which wouldn't meet the bar for Windows App SDK 1.1. |
Is this being worked on? It's not only that changes to grid definitions do not work, but hot reload is completely broken, if you are using the simplified syntax on a page. That's not acceptable. |
Can hot reload please be fixed? |
You should log a visual studio bug using the feedback tool. I agree this is super annoying and the main reason I don't even use the feature I suggested. |
@Balkoth We've been tracking that issue internally and haven't forgotten about it, but unfortunately it's not likely to be fixed soon (I'm sorry, I'm sure that wasn't the outcome you were hoping for). Feel free to create a separate issue in this repo, though, if you'd like to be notified when the internal status changes. |
To me its crazy that hot reload always gets mentioned when the question about a real designer comes up and then hot reload gets broken by new features. I will just ignore this feature, as it is not worth the hassle. |
This is on point. If Hot Reload is meant to be the "alternative" to XAML Designer, at least the team should keep focus on robustness. Not being able to dynamically change cols/rows would be acceptable, but the syntax breaks the feature completely |
I have hit the hot reload issue as well, indeed after the removal of all |
The problem is for the unsuspecting developer using the feature. After some work he discovers Hot Reload is not working, and needs to traceback until the moment it did. Just then he realizes that the abbreviated syntax provokes this bug. This is time consuming and annoying. |
I also have this problem, how to fix it? |
@RoccoZero use the feedback tool in Visual Studio and keep the pressure on to fix this. It’s super annoying |
Summary
The proposal is to simplify the definition syntax of Rows and Columns by:
Goal
The goal of this feature is to make Grid easier and more intuitive to write and learn. A major consideration for this proposal is to assure that any new syntax can work as a generalized language feature to fit other use cases across XAML.
Example
Current Syntax
Defining columns and rows is overly tedious, repetitive and not very productive, as is shown below:
Proposed Syntax
The same functionality as above with the proposed succinct syntax is shown below:
The following syntax will also be valid after the new language feature is implemented:
Rationale
A new grid syntax would not only improve developer satisfaction and productivity but would also minimize the learning curve required to use Grid, one of the most widely used controls. The original syntax would be kept in place to use for more complex scenarios and so older applications don’t have to be changed.
Implementing the succinct syntax will require the creation of a new XAML language feature, as typeconverters cannot be created for or used on read-only collections (which ColumnDefinitions and RowDefinitions are). In creating this new language feature, we wanted to make sure the syntax can be generalized for possible future use cases, including collections that may include Point objects, sets, or even string values that contain commas themselves. A comma-and-quotes-separated list is intuitive for single values (such as column heights), but is also readable for more complex types, such as Points. Examples of different syntax scenarios are below:
Succinct syntax for Grid definitions (numerical values)
Succinct syntax for more complex types of values
Scope
Appendix
A syntax that uses a list separated by commas and quotes was chosen due to:
The text was updated successfully, but these errors were encountered: