Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/angrycarrot789/wpf-codegen-converter
Uses a C# compiler to generate a WPF converter from a script, to save having to create a class for each converter
https://github.com/angrycarrot789/wpf-codegen-converter
csharp wpf
Last synced: 4 days ago
JSON representation
Uses a C# compiler to generate a WPF converter from a script, to save having to create a class for each converter
- Host: GitHub
- URL: https://github.com/angrycarrot789/wpf-codegen-converter
- Owner: AngryCarrot789
- License: mit
- Created: 2023-08-12T10:14:07.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2023-08-12T10:31:49.000Z (over 1 year ago)
- Last Synced: 2023-08-12T11:28:03.270Z (over 1 year ago)
- Topics: csharp, wpf
- Language: C#
- Homepage:
- Size: 16.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# WPFCodeGenConverter
Uses a C# compiler to generate a WPF converter from a script, to save having to create a class for each converterThis is purely just a demo of how to do it. But the added hassle of having to use special character codes like `"` instead of `"` and not
being able to use `using` statements (and having to directly access all types like `System.Windows.Visibility` directly)
almost make it not as convenient to use.Though 1 good usage I guess could be an invert bool converter, but you could just make a singleton bool inverter converter that you use across your
entire project# DynamicCodeConverter
To use it in XAML, you just set a binding's converter to `Converter={c:DynamicCodeConverter}`. The class extends `MarkdownExtension`, which means that you
don't need to provide a specific instance; it's automatically created by XAML and also the class itself (via the `ProvideValue` method)And then you provide your code in the `ConverterParameter` part of the binding. If the `ConverterParameter` is the last part of the binding expression, you can
encapsulate the script in single quotes (`'like this'`), and XAML will tolerate itCurrently, you can't convert back from the value. I was thinking of maybe using a TypeConverter or something along those lines to
allow more specific properties to be set... but then you lose the luxury of binding AFAIK. I couldn't get binding to work outside of the built in
`Binding`