Automatic binding #8680
Unanswered
Peter-Butler
asked this question in
Language Ideas
Replies: 1 comment
-
The following is abstracted from https://learn.microsoft.com/enus/dotnet/maui/fundamentals/databinding/binding-mode?view=net-maui-9.0#viewmodels-and-property-change-notifications public class HslColorViewModel : INotifyPropertyChanged
{
[binding]
{
Color color;
string name;
float hue;
float saturation;
float luminosity;
}
color = Color.FromHsla(hue, saturation, luminosity);
[binding] string name = NamedColor.GetNearestColorName(color);
}```
It’s much shorter to accomplish the same result.
I have no preference for the eventual syntax. The word “binding” in square brackets looked reasonable to me. Binding groups is a natural extension of binding single items.
It might be reasonable to have one instance of HslColorViewModel.
```C#
HslColorViewModel demo;```
Then in an xaml file:
Label … {Binding demo.color} /> |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
It's because I'm having problems with binding but wouldn't it be nice to have something like this:
[binding] int rotation;
and the same for class fields.
For many items syntax like
[binding]
{
int a;
int b;
} // could save a little typing
Might be related: #6846
Beta Was this translation helpful? Give feedback.
All reactions