How to define and use resources in xaml so they can be used in C#

前端 未结 4 1838
时光取名叫无心
时光取名叫无心 2020-12-16 12:35

Theoretically, I think that I can define Brushes and Colors etc. in an xaml file and assign that to a button.background in c#. But how do I do that? Where do I put my linear

4条回答
  •  一生所求
    2020-12-16 13:28

    You can access the application resources as

    Application.Current.Resources["BlaBrush"] as LinearGradientBrush
    

    Or, you add the resource to the control's resources and access them like Quartermeister wrote.

提交回复
热议问题