【问题标题】:C# WPF MVVM Caliburm-micro Binding `GradientStops` dynamicallyC# WPF MVVM Caliburm-micro 动态绑定`GradientStops`
【发布时间】:2017-08-04 13:40:58
【问题描述】:

我需要使用动态创建的LinearGradientBrush 创建组件。

我尝试过的:

查看:

<Grid.Background>
   <LinearGradientBrush  EndPoint="0.5,1"
                         MappingMode="RelativeToBoundingBox" 
                         StartPoint="0.5,0" 
                         GradientStops="{Binding ColorsThresholds }">
   </LinearGradientBrush>
</Grid.Background>

视图模型:

public class MyViewModel: Screen
{
    public BindableCollection<GradientStop> ColorsThresholds
    {
        get
        {
            return = GenerateRanges();
        }
    }
    private BindableCollection<GradientStop> GenerateRanges()
    {
        //Some generating stuff
    }

    public MyViewModel()
    {
         NotifyOfPropertyChange(()=> ColorsThresholds);
    }


}

ColorsThresholds 生成良好,但仍不可见。

【问题讨论】:

    标签: c# wpf mvvm caliburn.micro


    【解决方案1】:

    GradientStops 的类型为 GradientStopCollection,正如您从 here 中看到的那样。而不是BindableCollection&lt;GradientStop&gt; 使用GradientStopCollection

    【讨论】:

      猜你喜欢
      • 2012-06-13
      • 2013-02-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多