Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
250
"File selection" Field
posted

 Hi everyone,

I would like to create in XamDataGrid a column with a XamTextEditor and a Button.

What I want is an editabile File selection column.
How can I implement this feature?

I do that bin this way:

        <Style TargetType="{x:Type igs:CellValuePresenter}" x:Key="myCustomFieldCell">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type igs:CellValuePresenter}">
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="0.8*"></ColumnDefinition>
                                <ColumnDefinition Width="30"></ColumnDefinition>
                            </Grid.ColumnDefinitions>
                            <igE:XamTextEditor BorderThickness="0"
                                               VerticalAlignment="Center"
                                               Text="{TemplateBinding Content}">

                            </igE:XamTextEditor>
                            
                            <Button Grid.Column="1" Content="..." Width="30"
                                    Command="{x:Static ui:Window2.OpenProgramCommand}"/>
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>


But I have several problem when I select the cell and with the edit mode. I can edit only after 2 click when I cahnge row selection. Can you help me? Thanks in advance.

  • 250
    Verified Answer
    posted

     I solved by this way:

     

        <Style TargetType="{x:Type igDP:CellValuePresenter}" x:Key="fileSelectionColumn">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type igDP:CellValuePresenter}">
                        <Grid ToolTip="{TemplateBinding Content}" Height="22">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="0.8*"></ColumnDefinition>
                                <ColumnDefinition Width="30"></ColumnDefinition>
                            </Grid.ColumnDefinitions>
                            <ContentPresenter Name="PART_EditorSite">
                                <ContentPresenter.Content>
                                    <igE:XamTextEditor VerticalContentAlignment="Center" VerticalAlignment="Center"
                                                       Text="{TemplateBinding Content}"/>
                                </ContentPresenter.Content>
                            </ContentPresenter>
                            <Button Grid.Column="1" Content="..." Width="30" Height="20" VerticalAlignment="Center"
                                    Command="{x:Static ui:WorklistPresentationModel.SelectProgramCommand}"/>
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>