Proposal: x:Bind should be able to reference enums and const
See original GitHub issueFollowing good programming practice, I try to define my “magic strings” as constants. If I need to use the same string in both XAML and C#, I can define it in C# as a constant, but there is no way to reference it in the XAML so I end up having to define it again in as a static resource. In WPF this could be partially solved by defining it as a static readonly string and referencing it with {x:Static}, but this is not available in UWP and {StaticResource} does not have the same functionality.
As an example, I’m trying to do this:
<TextBlock Text="{x:Bind SomeProperty, Converter={StaticResource MyConverter}, ConverterParameter=MyCustomFormat}" />
where MyCustomFormat is a string constant defined and used in the code-behind.
Please add the ability to refer to C# constants and static fields in UWP XAML.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:6
- Comments:6 (4 by maintainers)
Top GitHub Comments
I agree that x:Bind should be able to reference enums and const.
@jeremiahmercier-3136, are you saying that WPF’s x:Static and Xaml’s x:Bind both support static, but neither support const?
(I agree with having the feature)