This is a migrated thread and some comments may be shown as answers.

RadColorPaletteView SelectedColor ?

2 Answers 126 Views
ColorPicker
This is a migrated thread and some comments may be shown as answers.
Daniel Ruehle
Top achievements
Rank 1
Daniel Ruehle asked on 08 Jul 2010, 11:42 AM
Hello telerikTeam,

I have an Issue with the SelectedColor in the RadColorPaletteView namely how can I get selectedColor ?
If I try this:

RadColorPaletteView colorPalette = sender as RadColorPaletteView;
 
RadColorPaletteViewItem selectedItem = colorPalette.SelectedItem;

I am getting null.

Could you please tell me what I am doing wrong ?

XAML
<telerik:RadColorPaletteView x:Name="BorderColor" Margin="0" Grid.Column="1" Palette="Standard" PaletteOrientation="Horizontal" Style="{StaticResource RadColorPaletteViewStyle}" VerticalAlignment="Center" PreviewMouseLeftButtonDown="ChangeColor"/>




Thank you.

Daniel

2 Answers, 1 is accepted

Sort by
0
Daniel Ruehle
Top achievements
Rank 1
answered on 08 Jul 2010, 11:54 AM
Hello,

I found out. I used just a wrong event Handler. But how can I access SelectedPalleteViewItem Property ?

BR,
Daniel
0
Viktor Tsvetkov
Telerik team
answered on 13 Jul 2010, 01:58 PM
Hello Daniel,

What exactly do you mean by saying "access the SelectedPalleteViewItem property". The reason why I am asking is because RadColorPaletteView does not contain a property called SelectedPalleteViewItem. It has a SelectedItem property which is of type Color. To access it, you can subscribe for the SelectionChanged event of RadColorPaletteView and obtain the selected color from there:

<telerik:RadColorPaletteView x:Name="BorderColor" Margin="0" Grid.Column="1"
        Palette="Standard" PaletteOrientation="Horizontal" VerticalAlignment="Center"
        SelectionChanged="ChangeColor" />

private void ChangeColor(object sender, SelectionChangedEventArgs e)
{
    if (BorderColor.SelectedItem != null)
    {
        MessageBox.Show(((Color)BorderColor.SelectedItem).ToString());
    }
}

I'm attaching my sample project for reference. Have a look at it and let me know how I can be of further assistance.

All the best,
Viktor Tsvetkov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
ColorPicker
Asked by
Daniel Ruehle
Top achievements
Rank 1
Answers by
Daniel Ruehle
Top achievements
Rank 1
Viktor Tsvetkov
Telerik team
Share this question
or