'Cannot find governing FrameworkElement…' warning when binding inside DataTemplates

前端 未结 1 1617
不思量自难忘°
不思量自难忘° 2020-12-18 21:30

I\'m getting this warning in Visual Studio output window when binding on a SolidColorBrush property inside a DataTemplate:

System.Windows.Dat

相关标签:
1条回答
  • 2020-12-18 22:22

    Binding with default data source as DataContext wont work for SolidColorBrush type as they are not framework elements. Plus they are freezable and you are not allowed to change their colors dynamically through data context based color binding.

    Either you will have to bind the color to the background fill via a converter that converts the color into a solid color brush.

     <TextBlock Background="{Binding MyColor,
                                    Converter={StaticResource ColorToBrushConverter}}" />
    

    Or use Color as DynamicResource and refer that in Solid Color Brush.

    ControlTemplate Storyboard color animation problem

    0 讨论(0)
提交回复
热议问题