-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Implement a preprocessor for C# like JSX. CSX? #10316
Comments
tip: use ```C# line to start a code block and ``` line to end it It's runtime parsing rather than compiling, but would |
That sounds good, but i was suggesting just typing the XAML. i will start using that though |
The issue is this request is more of a C# compiler request rather than WPF request. Note that VB.NET does have XML literals, but the C# team decided not to do that, so that is an indication of their position. Technically, WPF allows you to do that by means of XAML files. If you put your snippet into a XAML file, the compiler will sort of pre-compile it into BAML which you can access from the application. The advantage of this is you get full intellisense. I think the best compromise you could get nowadays is to write a Roslyn source generator. Have your XAML stored e.g. in a string constant and the source generator will create a corresponding method or property that would return the object. |
We can write the C# code in XAML, such as: <Grid>
<Button Name="Button" HorizontalAlignment="Center" VerticalAlignment="Center"
Click="Button_OnClick">The Button</Button>
@code
{
void Button_OnClick(object sender, RoutedEventArgs e)
{
Button.Content = "The new content";
}
}
</Grid> |
ok then. thanks |
I don't like databindings and tend to handle repetitive instances of a component in code. For example, I have code like this
What if I could simplify the code to something like this?
I feel like this would be a really helpful feature.
The text was updated successfully, but these errors were encountered: