C# WPF MVVM Caliburm-micro 动态绑定`GradientStops`
C# WPF MVVM Caliburm-micro Binding `GradientStops` dynamically
我需要使用动态创建的组件创建组件 LinearGradientBrush
。
我尝试过的:
查看:
<Grid.Background>
<LinearGradientBrush EndPoint="0.5,1"
MappingMode="RelativeToBoundingBox"
StartPoint="0.5,0"
GradientStops="{Binding ColorsThresholds }">
</LinearGradientBrush>
</Grid.Background>
ViewModel:
public class MyViewModel: Screen
{
public BindableCollection<GradientStop> ColorsThresholds
{
get
{
return = GenerateRanges();
}
}
private BindableCollection<GradientStop> GenerateRanges()
{
//Some generating stuff
}
public MyViewModel()
{
NotifyOfPropertyChange(()=> ColorsThresholds);
}
}
ColorsThresholds
生成的很好,但是还是看不到。
GradientStops
是 GradientStopCollection
类型,从 here 可以看出。而不是 BindableCollection<GradientStop>
使用 GradientStopCollection
.
我需要使用动态创建的组件创建组件 LinearGradientBrush
。
我尝试过的:
查看:
<Grid.Background>
<LinearGradientBrush EndPoint="0.5,1"
MappingMode="RelativeToBoundingBox"
StartPoint="0.5,0"
GradientStops="{Binding ColorsThresholds }">
</LinearGradientBrush>
</Grid.Background>
ViewModel:
public class MyViewModel: Screen
{
public BindableCollection<GradientStop> ColorsThresholds
{
get
{
return = GenerateRanges();
}
}
private BindableCollection<GradientStop> GenerateRanges()
{
//Some generating stuff
}
public MyViewModel()
{
NotifyOfPropertyChange(()=> ColorsThresholds);
}
}
ColorsThresholds
生成的很好,但是还是看不到。
GradientStops
是 GradientStopCollection
类型,从 here 可以看出。而不是 BindableCollection<GradientStop>
使用 GradientStopCollection
.