我找保持我们在应用程序中的所有RadColorPicker实例相同的近期彩色列表WPF RadColorPicker相同颜色的最近清单。即G。如果用户从一个颜色拾取(和colorEditor)控件创建一个自定义颜色,用户不必再拾色器这么做。用户应该在所有拾色器的近期颜色中看到相同的颜色。维护应用程序
我想弄清楚,如何实现它。我看到属性RecentColorsItemsSource,这可能在这里使用,但是,我无法得到它的工作。我正在尝试使用“RecentColorsItemsSource”属性来设置示例颜色,但是我遇到了运行时错误。以下是XAML代码和后台代码的代码:
的XAML:
<telerik:RadColorPicker x:Name="myColorPicker" IsRecentColorsActive="True" RecentColorsItemsSource="{Binding Path=MyColors}" />
代码隐藏或视图模型:
但与此代码我收到此错误:
对象未将引用设置为对象的实例。
at Telerik.Windows.Controls.RadColorSelector.BindRecentColorsPalette()
at Telerik.Windows.Controls.RadColorSelector.BindXamlElements()
at Telerik.Windows.Controls.RadColorSelector.OnApplyTemplate()
at System.Windows.FrameworkElement.ApplyTemplate()
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element, Size constraint)
at System.Windows.Controls.ContentPresenter.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.Controls.Control.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
这里的一些帮助是可观的。
,当我们使用单一颜色选择器帮助。我的场景的例子是,比方说我们在网格的颜色列中使用颜色选择器,那么第一行颜色选择器的最近颜色将不会出现在第二个颜色选择器中,依此类推。 – Randeep
我编辑了我的答案 – Ahmed
我也探讨了同样的情况,但是在使用它时我得到了空引用异常,我无法弄清楚我在哪里得到这个。我正在使用此代码来设置此集合。 radColorPicker.RecentColorsItemsSource = new List {Colors.Red,Colors.Pink}; –
Randeep