-
Notifications
You must be signed in to change notification settings - Fork 693
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
[Feature] x:Bind should support general string indexers without interface in C# #3064
Comments
FYI @oldnewthing even showed a string indexer as an example in his article here in the opening paragraph: <TextBlock Text=”{x:Bind Players[‘John Smith’]” /> Thanks @chingucoding for the article link! 🦙❤ |
@michael-hawker As he quoted from the documentation, here's the official part: https://docs.microsoft.com/en-us/windows/uwp/xaml-platform/x-bind-markup-extension#collections |
Thanks @Felix-Dev, @chingucoding just pointed me to that doc as well. I think the "functions in x:Bind doc" should link to the main article, I'll open up a doc issue about that. So it seems like this is a feature request then as this is currently expected behavior as documented. Just not looking at the right doc... 😋 |
As noted in the documentation, the collection must be mutable. But your indexer is read-only.
|
@StephenLPeters I understand that this was not intended as designed originally, but this is still a feature request. Is there a reason the collection needs to be mutable to support this feature? Can we get a few more details here? I know it'll still need WinUI 3 to be fixed most likely in the future, if possible. Thanks! |
Sorry the triage team interpretated the conversation differently. We can reuse this as a feature proposal |
@StephenLPeters can we get this re-opened as a feature request for the future? Thanks! |
Hey @michael-hawker this is something that would need to come in WinUI 3, but it is not currently something we are currently looking at. Would you be able to go into more detail on what scenarios you are trying to support here so our team can re-evaluate this? |
@JeanRoca the scenario we had came directly from us trying to make it easier to integrate our XAML presenter with the Graph SDK. The Graph SDK is just .NET Standard based, so it's using base interface/types that we wouldn't be able to modify. It'd be great if x:Bind could just use the indexer overload if one exists on whatever object it's dealing with. |
Alright I see thank you for the insight. I will go ahead and place it in the backlog, but can't quite guarantee an ETA for it yet. I will leave the issue open. |
@JeanRoca @StephenLPeters @oldnewthing does this restriction apply to regular bindings and VisualStates as well? @ismaelestalayo was just trying to change <VisualState x:Name="NarrowState">
<VisualState.StateTriggers>
<AdaptiveTrigger MinWindowWidth="0" />
</VisualState.StateTriggers>
<VisualState.Setters>
<Setter Target="(DataGrid.Columns)[0].Width" Value="0"/>
<Setter Target="(DataGrid.Columns[1]).Width" Value="0"/>
<Setter Target="(DataGrid.Columns.DataGridTemplateColumn[2]).Width" Value="0"/>
</VisualState.Setters>
</VisualState> |
I solve this bug with an xaml extension to bind XAML to an string index property without c# interface see CommunityToolkit/Labs-Windows#236 If microsoft aprove the spec i will submit the code |
@JeanRoca |
Describe the bug
The documentation for x:Bind here in the 'path to the function' section specifies:
However, it appears that non-integer based indexers, e.g. strings, are not supported?
I was trying to bind directly to a Graph function with the Windows Community Toolkit's
GraphPresenter
:As these classes use string indexers to build the query to the Graph, E.g.
However VS tells me in the x:Bind expression that I have provided an "invalid index value" and "WMC1110: Invalid binding path ... Unexpected array indexer".
Expected behavior
I would have expected string indexers to work just as I can pass them into function parameters with x:Bind in single-quotes.
Version Info
NuGet package version: WUX
The text was updated successfully, but these errors were encountered: