Skip to content
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

[Question] [DataGrid] Binding RowStyle Foreground/Background #4186

Closed
brinko99 opened this issue Aug 19, 2021 · 4 comments
Closed

[Question] [DataGrid] Binding RowStyle Foreground/Background #4186

brinko99 opened this issue Aug 19, 2021 · 4 comments
Labels
by design DataGrid 🔠 Issues on DataGrid control question ❔ Issues or PR require more information sdkcheck 🏁 wontfix ❌ Discontinued Issues or PR

Comments

@brinko99
Copy link

I'm new to UWP, coming from WPF.

I'm struggling to bind the DataGrid's RowStyle Foreground (and Background) properties. The scenario is a log message viewer where the row color indicates the log message severity.

<controls:DataGrid.RowStyle>
    <Style TargetType="controls:DataGridRow">
        <Setter Property="Foreground">
            <Setter.Value>
                <Binding Path="Level"
                         Converter="{StaticResource LogLevelForegroundColorConverter}"/>
            </Setter.Value>
        </Setter>
    </Style>
</controls:DataGrid.RowStyle>

The above produces a NullReferenceException in DataGridRow.EnsureForeground(). Examining the code, it's hard to see where the null reference might be coming from.

This similar issue on SO has an answer that suggests that this is not possible with UWP / DataGrid, though the explanation is wanting. That's hard to believe, but perhaps I'm missing some fundamental limitation here.

Any help is appreciated.

Toolkit: 7.0.2
Windows: 1909

@brinko99 brinko99 added the question ❔ Issues or PR require more information label Aug 19, 2021
@ghost ghost added the needs triage 🔍 label Aug 19, 2021
@ghost
Copy link

ghost commented Aug 19, 2021

Hello brinko99, thank you for your interest in Windows Community Toolkit!

I have automatically added a "needs triage" label to help get things started. Our team will analyze and investigate the issue, and escalate it to the relevant team if possible.. Other community members may also answer the question and provide feedback 🙌

@michael-hawker
Copy link
Member

Binding in styles is not supported by UWP. Direct link to Migration Notes in docs and open WinUI issue on this topic.

@michael-hawker michael-hawker added by design DataGrid 🔠 Issues on DataGrid control sdkcheck 🏁 wontfix ❌ Discontinued Issues or PR and removed needs triage 🔍 labels Aug 19, 2021
@brinko99
Copy link
Author

Wow... fundamental limitation indeed. And this looks to be the same for WinUI 3 :-(

Thanks for the quick answer.

@michael-hawker
Copy link
Member

@brinko99 yeah, hopefully when they get to the backlog of items for WinUI 3, after 1.0+, it'll be on the list. WPF compat is certainly on their radar. I've tagged that issue with the appropriate label for that as it was missing.

@ghost ghost locked as resolved and limited conversation to collaborators Nov 3, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
by design DataGrid 🔠 Issues on DataGrid control question ❔ Issues or PR require more information sdkcheck 🏁 wontfix ❌ Discontinued Issues or PR
Projects
None yet
Development

No branches or pull requests

2 participants