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
300
Set focus on Record
posted

When one Button is clicked. i wan to do ...

set focus on teh 5th cell of Record...

this

 

.xamdataGrid.Records[0].FieldLayout.Fields[5].IsSelected = true;

 

but i observe that systm does not set focus ..Below is the style applied to the field

 

 

<Style x:Key="cvpWhiteWithGrayText" TargetType="igDP:CellValuePresenter">

 

 

<Setter Property="Background" Value="#FFFFFFFF"/>

 

 

<Setter Property="Foreground" Value="#FFCFCFCD"/>

 

 

<Setter Property="Template">

 

 

<Setter.Value>

 

 

<ControlTemplate TargetType="igDP:CellValuePresenter">

 

 

<Border Background="#FFFFFFFF" BorderBrush="Gray" BorderThickness="0,0,0.5,0" HorizontalAlignment="Stretch">

 

 

<Grid Background="Transparent" HorizontalAlignment="Stretch">

 

 

<TextBox GotFocus="TextBox_GotFocus" LostFocus="TextBox_LostFocus" BorderBrush="Transparent" BorderThickness="0" Background="#FFFFFFFF" Foreground="#FFCFCFCD" Text="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Value}"/>

 

 

</Grid>

 

 

</Border>

 

 

</ControlTemplate>

 

 

</Setter.Value>

 

 

</Setter>

 

 

</Style>

-----------------------------------------

Parents
  • 69686
    posted

    Hello,

    From the code that you have provided, you are trying to set the IsSelected property of the field. You need to do this on the cell. The Cells collection is exposed by the DataRecord. What you need to do is to cast your record (for example xamDataGrid.Records[0] as DataRecord) and then access the cells collection.

    You can set the IsActive property of the cell and then invoke the StartEditMode command (xamDataGrid.ExecuteCommand(DataPresenterCommands.StartEditMode).

    However, this would not work with the style you have provided. You have retemplated the CellValuePresenter's template and therefore interrupted the connection between the XamDatagrid and the cell. The CellValuePresenter uses PART-named elements which should not be removed.

    Please note that you should use our default styles which we ship in the DefaultStyles directory and use then as base for your own custom ones. You should also avoid removing the Part-named elements inside these templates.

Reply Children
No Data