开发者

How to bind an indexer to a GridViewColumn in WPF?

In my ViewModel object I have a this indexer like:

public bool this[enum effectType]
{
    get { return CheckList.First ( e => e.EffectType =开发者_JAVA百科= effectType ).IsChecked; }
}

but not sure how to bind this in Xaml. I have tried these:

<GridViewColumn
    <GridViewColumn.CellTemplate>
        <DataTemplate>
            <CheckBox
                IsChecked="{Binding Item[Blur], Mode=TwoWay}"/>
        </DataTemplate>
    </GridViewColumn.CellTemplate>
</GridViewColumn>

IsChecked="{Binding this[Blur], Mode=TwoWay}"/>

IsChecked="{Binding AllEffects[Blur], Mode=TwoWay}"/>

AllEffects is an ObservableCollection already binded to the ListBox itself and the columns are already populated except the checked ones which I am trying to bind to this indexer.


Try this:

<CheckBox IsChecked="{Binding .[Blur], Mode=TwoWay}"/>

Please note that your indexer property must provide a setter in order TwoWay binding to work.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜