How can I list colors in WPF with XAML?

前端 未结 4 902
耶瑟儿~
耶瑟儿~ 2020-12-05 08:14

How can I get list of all colors I can pick in Visual Studio Designer (which is System.Windows.Media.Colors, but that isn\'t a collection) and put them into my

4条回答
  •  南方客
    南方客 (楼主)
    2020-12-05 08:52

    Here is the pure XAML solution.

    In your resources section, you would use this:

    
    .. xmlns:sys="clr-namespace:System;assembly=mscorlib" ..
    
    
        
            System.Windows.Media.Colors, PresentationCore,
                Version=3.0.0.0, Culture=neutral, 
                PublicKeyToken=31bf3856ad364e35
        
    
    
    
    

    Or, as CodeNaked points out, it can be reduced to one tag:

    
    

    And then the combobox would look like this:

    
    

提交回复
热议问题