0
我在WPF中創建了一個自定義按鈕控件,當我嘗試使用它時,設計器中的背景刷屬性,它不會改變任何內容。這當然是因爲我需要在XAML中將屬性綁定在一起。我已經試過:綁定自定義控件背景顏色屬性的最佳方法
<Button Content="Button" Background="{Binding Background, FallbackValue=White}"/>
如果我不使用fallbackvalue,我能夠使用設計器來設置背景顏色,但使用它,我不能,這意味着我不能設置默認。有任何想法嗎?
如果這是在一個UserControl中,你應該寫'{Binding Background,RelativeSource = {RelativeSource AncestorType = UserControl}}'。 – Clemens