开发者

How to bind a Dictionary<enum,bool> property to a GridViewColumn?

I am tryin开发者_如何学编程g to bind a Dictionary property stored in a EffectViewModel inside an ObservableCollection, but it appears as "(Collection)" in the column I want to see as checkboxes.

Xaml for the GridViewColumn is this:

<GridViewColumn
    Width="100"
    Header="GPU"
    DisplayMemberBinding="{Binding ShaderSupport}">
    <GridViewColumn.CellTemplate>
        <DataTemplate>
            <CheckBox Margin="0"
                        HorizontalAlignment="Center"
                        IsChecked="{Binding Value}"/>
        </DataTemplate>
    </GridViewColumn.CellTemplate>
</GridViewColumn>

ShaderSupport is of type Dictionary<ShaderType, bool> where I just want to read in the bool value for ShaderType.GPU for this GridViewColumn.

Any ideas?

EDIT: Using this shows me the bool value as string, so I am in the right path I think:

DisplayMemberBinding="{Binding ShaderSupport[GPU]}">


Try this:

<GridViewColumn
    Width="100"
    Header="GPU">
    <GridViewColumn.CellTemplate>
        <DataTemplate>
            <CheckBox Margin="0"
                        HorizontalAlignment="Center"
                        IsChecked="{Binding ShaderSupport[CPU]}"/>
        </DataTemplate>
    </GridViewColumn.CellTemplate>
</GridViewColumn>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜