Skip to content

PortableColorPicker in DataGridCell: Can't switch between primary to secondary color #33

@Kruemelino

Description

@Kruemelino

Hi,

thank you for your work.

I've added a PortableColorPicker to a DataGridTemplateColumn of a DataGrid. Everything looks fine so far, but I can't switch between the primary and secondary colors.

What am I doing wrong? If I use the PortableColorPicker outside of the DataGrid, the switch between the colors is possible. Even if I add the StandardColorPicker into the DataGridTemplateColumn everything is ok.

Here is my example:

<Window x:Class="MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:WpfAppTest"
        xmlns:cp="clr-namespace:ColorPicker;assembly=ColorPicker"
        mc:Ignorable="d"
        Title="MainWindow" Height="450" Width="800">

    <Window.Resources>
        <XmlDataProvider x:Key="MockList" XPath="/MockObjects/*" >
            <x:XData >
                <MockObjects xmlns="">
                    <MockObject />
                </MockObjects>
            </x:XData>
        </XmlDataProvider>
    </Window.Resources>

    <Grid DataContext="{Binding Source={StaticResource MockList}}">
        <DataGrid ItemsSource="{Binding Mode=Default, XPath=/MockObjects/MockObject}" 
                  AutoGenerateColumns="False">
            
            <DataGrid.Columns>

                <DataGridTemplateColumn Header="PortableColorPicker">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <cp:PortableColorPicker ShowAlpha="True" Height="14"/>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>

                <DataGridTemplateColumn Header="StandardColorPicker">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <cp:StandardColorPicker ShowAlpha="True" />
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>

            </DataGrid.Columns>
        </DataGrid>

    </Grid>
</Window>

Thank you für your help

Addition:
The selected items will not work in this case.
image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions