我用我的計劃之內這個的ObservableCollection級:Link
我想綁定RibbonMenuButton到ObservableDictionary<string,bool>
:WPF:綁定到一個(可觀察)字典
<r:RibbonMenuButton ItemsSource="{Binding MyDictionary}">
<r:RibbonMenuButton.ItemContainerStyle>
<Style TargetType="{x:Type r:RibbonMenuItem}">
<Setter Property="IsCheckable" Value="true"/>
<Setter Property="Header" Value="{Binding Path=Key}"/>
<Setter Property="IsChecked" Value="{Binding Path=Value}"/>
</style>
</r:RibbonMenuButton.ItemContainerStyle>
</r:RibbonMenuButton>
,但我得到的例外,因爲內部IDictionary-KeyValuePairs的Value-Properties屬性是隻讀的。任何想法如何解決這個問題?
我想過是這樣的:
<Setter Property="IsChecked" Value="{Binding Source=MyDictionary[{Binding Path=Key}]}"/>
但是這是不行的「{}綁定在{結合}的原因...
元組......這就是我正在尋找的類,工程PERFEKT我! – Reini 2011-05-17 11:51:06
narf ... Touple.Item1/2也是隻讀的。所以我打算用輔助班,努力避免這種... – Reini 2011-05-17 11:58:21
@Reini:哎呀。對不起...... – 2011-05-17 11:59:19