1
我試圖使用this example來設計TreeView
的樣式,並且一切正常,直到我嘗試將綁定添加到我的DataContext
。也就是說,我將Paths
的Fill
替換爲MultiBinding
的箭頭至當前主題。這裏是相對碼:TreeView模板:綁定返回null
<Path x:Name="Collapsed" HorizontalAlignment="Left" VerticalAlignment="Center"
Margin="1" Data="M 4 0 L 8 4 L 4 8 Z">
<Path.Fill>
<SolidColorBrush>
<SolidColorBrush.Color>
<MultiBinding Converter="{StaticResource ThemeToColorConverter}"
ConverterParameter="Foreground">
<Binding Path="Themes" />
<Binding Path="ThemeIndex" />
</MultiBinding>
</SolidColorBrush.Color>
</SolidColorBrush>
</Path.Fill>
</Path>
我已經設置在轉換器中的斷點,這個問題似乎是兩個Bindings
找不到自己Paths
,因爲它們都發送null
到轉換器。不過,我在代碼的早期設置Button
樣式時使用了相同的代碼,並且按鈕顯示完美。
我能想到的唯一的事情是,在TreeView Style
,Bindings
從不同的來源拉。我只是不知道他們會怎麼做或如何解決這個問題。謝謝!
是否有在輸出窗口綁定例外? – Andy
是的,其實。這裏:'System.Windows.Data錯誤:2:找不到目標元素的控制FrameworkElement或FrameworkContentElement。 BindingExpression:路徑=主題;的DataItem = NULL;目標元素是'SolidColorBrush'(HashCode = 31542128);目標屬性是'顏色'(類型'顏色')' – benjer3
好吧,我想我可能會擁有它。 'MultiBinding'試圖從每個'Item'的'Source'拉取。現在如何解決它.... – benjer3