-
- MarcusM-PDX
- Posts: 4
- Joined:
WPF cannot get the length from a String, because it's actually Boxed<String>
Error Message
[Noesis - Binding]: Can't solve PropertyPath: Type 'Boxed<String>' does not contain a property named 'Length'
[Noesis - Binding]: Binding failed: Path=CustomText.Length, Source=Game.TechnologyWrapper(''), Target=Button('Slot'), TargetProperty=Game.Custom.Int
Code
game:Custom.Int="{Binding CustomText.Length}"
Explanation
The situation is that as part of a Style (for a button) I'm trying to get the length of the CustomText Noesis::String. The binding for CustomText is working, as it's content is successfully displayed within the Style, and I'm attempting to make a convenient way to collapse the textbox if the content of CustomText is "". My approaches all seemed like they should work, but weren't and after drilling down and simplifying it, I realized that the point at which I'm binding the string is revealing the shown error, that the String is actually secretly a Boxed<String>.
Have I set something up wrong somewhere, or am I missing something?
Thanks!
[Noesis - Binding]: Can't solve PropertyPath: Type 'Boxed<String>' does not contain a property named 'Length'
[Noesis - Binding]: Binding failed: Path=CustomText.Length, Source=Game.TechnologyWrapper(''), Target=Button('Slot'), TargetProperty=Game.Custom.Int
Code
game:Custom.Int="{Binding CustomText.Length}"
Explanation
The situation is that as part of a Style (for a button) I'm trying to get the length of the CustomText Noesis::String. The binding for CustomText is working, as it's content is successfully displayed within the Style, and I'm attempting to make a convenient way to collapse the textbox if the content of CustomText is "". My approaches all seemed like they should work, but weren't and after drilling down and simplifying it, I realized that the point at which I'm binding the string is revealing the shown error, that the String is actually secretly a Boxed<String>.
Have I set something up wrong somewhere, or am I missing something?
Thanks!
-
-
sfernandez
Site Admin
- Posts: 2869
- Joined:
Re: WPF cannot get the length from a String, because it's actually Boxed<String>
Hi Marcus,
We have to improve the binding error message, because a Boxed<String> is handled in fact as a simple String by the binding system, so we should just show 'String' in that message. Anyway, the problem that is described in that binding error is not related to that. What happens is that Noesis String does not expose a Length property that can be bound like it happens in WPF/C#.
To solve this you can use a Converter that takes the string and returns its length:
Could you try that?
We have to improve the binding error message, because a Boxed<String> is handled in fact as a simple String by the binding system, so we should just show 'String' in that message. Anyway, the problem that is described in that binding error is not related to that. What happens is that Noesis String does not expose a Length property that can be bound like it happens in WPF/C#.
To solve this you can use a Converter that takes the string and returns its length:
Code: Select all
game:Custom.Int="{Binding CustomText, Converter={StaticResource StringToLengthConverter}}"
-
- MarcusM-PDX
- Posts: 4
- Joined:
Re: WPF cannot get the length from a String, because it's actually Boxed<String>
Using a converter to get the Length worked perfectly, even gave myself a few other features in the process.
Thanks!
Thanks!
Who is online
Users browsing this forum: Ahrefs [Bot] and 1 guest