This question is locked. New answers and comments are not allowed.
I am trying to put color picker in a dropdownbutton. I want once the user selects the color the dropdown should close.
My column defination
My column defination
<telerik:GridViewDataColumn Header="Color"
x:Name="Color"
DataMemberBinding="{Binding Path=ColorBrush, Mode=TwoWay}"
Width="40"
UniqueName="Color">
<telerik:GridViewDataColumn.CellTemplate>
<DataTemplate>
<telerik:RadDropDownButton Background="{Binding Path=ColorBrush, Mode=TwoWay}"
Name="ColorDropDown1"
Width="20" Height="15" DropDownWidth="187" CornerRadius="3"
DropDownIndicatorVisibility="Collapsed" >
<telerik:RadDropDownButton.DropDownContent>
<telerik:RadColorSelector
SelectedColor="{Binding Path=ColorBrush, Mode=TwoWay}"
SelectedColorChanged="RadColorPicker_SelectedColorChanged"/>
</telerik:RadDropDownButton.DropDownContent>
</telerik:RadDropDownButton>
</DataTemplate>
</telerik:GridViewDataColumn.CellTemplate>
in code I am trying to get to the control byprivate void RadColorPicker_SelectedColorChanged(object sender, EventArgs e)It only works for first row but not for all. Any help?
{
(mRadGridView.SelectedItem as ChannelProperty).ColorBrush = new SolidColorBrush((sender as RadColorSelector).SelectedColor);
RadDropDownButton button = FindVisualChildByName<RadDropDownButton>(this, "ColorDropDown1");
button.IsOpen = false;
}
private static T FindVisualChildByName<T>(DependencyObject parent, string name) where T : DependencyObject
{
for (int i = 0; i < VisualTreeHelper.GetChildrenCount(parent); i++)
{
var child = VisualTreeHelper.GetChild(parent, i);
string controlName = child.GetValue(Control.NameProperty) as string;
if (controlName == name)
{
return child as T;
}
else
{
T result = FindVisualChildByName<T>(child, name);
if (result != null)
return result;
}
}
return null;
}