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
240
cursor flashing inside the new record
posted

Hi all,

Is anyone know how to make the cursor flashing inside the new record or the selected record?

I using XamDatagrid version 9.1. I have a grid and also a button new and edit.

those are code I using in button new:

xamDataGrid.FieldLayoutSettings.AllowAddNew = true;

(xamDataGrid.RecordManager.CurrentAddRecord as DataRecord).Cells[xamDataGrid.FieldLayouts[0].Fields[0]].IsActive = true;
(xamDataGrid.RecordManager.CurrentAddRecord as DataRecord).Cells[xamDataGrid.FieldLayouts[0].Fields[0]].IsSelected = true;
 xamDataGrid.ExecuteCommand(DataPresenterCommands.StartEditMode);

with that code, the new record added and selected, but the cursor won't flashing in it.

It also happen if I click edit button.

those are code I using in button edit :

xamDataGrid.FieldLayoutSettings.AllowEdit = true;

(xamDataGrid.ActiveRecord as DataRecord).Cells[xamDataGrid.FieldLayouts[0].Fields[0]].IsActive = true;
(xamDataGrid.ActiveRecord as DataRecord).Cells[xamDataGrid.FieldLayouts[0].Fields[0]].IsSelected = true;
 xamDataGrid.ExecuteCommand(DataPresenterCommands.StartEditMode);

with that code, the selected record is in edit mode and selected, but the cursor won't flashing in it.

I need to click on the record first to make to cursor  flashing inside the record.

Is there anyone know how to solved this?

Thanks before,

Vera

Parents
  • 69686
    posted

    Hell Vera,

    I suppose you are referring to the Caret of the XamTextEditor. The "cursor" is the mouse cursor and it cannot be flashing. The caret is not showing, because when the XamTextEditor enters EditMode, the text inside it is selected. If you want the caret to appear when you hit that button, you have to de-select the text.

    You can do this by getting the CellValuePresenter of that cell and set the SelectionLength of the Editor.

    Here is how to do this (this will place the caret in the beginning of the XamTextEditor):

    (CellValuePresenter.FromCell(xamDataGrid1.ActiveCell).Editor as XamTextEditor).SelectionLength = 0;

    Just as a side note:
    First I though you want the mouse cursor to be flashing, which cannot be achieved, so I created a "flashing record style". I am going to paste it here anyway (it looks kind of cool):
     <Style TargetType="{x:Type igDP:DataRecordPresenter}">
                        <Style.Triggers>
                            <Trigger Property="IsActive" Value="True">
                                <Setter Property="Cursor" Value="Hand"/>
                                <Trigger.EnterActions>
                                    <BeginStoryboard>
                                        <Storyboard>
                                            <DoubleAnimation Storyboard.TargetProperty="Opacity" 
                                                             RepeatBehavior="Forever"
                                                             From="1" To="0.5" AutoReverse="True" Duration="0:0:0.5"/>
                                        </Storyboard>
                                    </BeginStoryboard>
                                </Trigger.EnterActions>
                                <Trigger.ExitActions>
                                    <BeginStoryboard>
                                        <Storyboard>
                                            <DoubleAnimation Storyboard.TargetProperty="Opacity" 
                                                             To="1"  Duration="0:0:0.5"/>
                                        </Storyboard>
                                    </BeginStoryboard>
                                </Trigger.ExitActions>
                            </Trigger>
                        </Style.Triggers>
                    </Style>
    Regards,
    Alex.

Reply Children