I have the following style defined and it works perfectly when assigned to the field's CellValuePresenterStyle property. Is there a way to generically bind so that I don't have to create styles for each field that might possibly use this style?
<Style x:Key="DataGridCellHyperlink" TargetType="{x:Type igDP:CellValuePresenter}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type igDP:CellValuePresenter}"> <TextBlock VerticalAlignment="Center" HorizontalAlignment="Left" Cursor="Hand" Foreground="Blue" TextDecorations="Underline" Text="{Binding RelativeSource={RelativeSource TemplatedParent},Path=Record.DataItem.model_id}"/> </ControlTemplate> </Setter.Value> </Setter> </Style>
Thanks,Rod
You can use triggers to set different controls whe the CellValuePresenter is active.
Here is an example,
<Style x:Key="MyStyle" TargetType="{x:Type igDP:CellValuePresenter}"> <Style.Triggers> <Trigger Property="IsActive" Value="True"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type igDP:CellValuePresenter}"> <TextBox Text="{Binding RelativeSource={RelativeSource TemplatedParent},Path=Value}" HorizontalAlignment="Stretch" VerticalAlignment="Center" TextAlignment="Right" Foreground="#FF151C55" Margin="0,0,0,4" Name="textBlock"/> </ControlTemplate> </Setter.Value> </Setter> </Trigger> <Trigger Property="IsActive" Value="False"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type igDP:CellValuePresenter}"> <TextBlock Text="{Binding RelativeSource={RelativeSource TemplatedParent},Path=Value}" HorizontalAlignment="Right" VerticalAlignment="Center" TextAlignment="Right" Foreground="#FF151C55" Margin="0,0,0,4" Name="textBlock"/> </ControlTemplate> </Setter.Value> </Setter> </Trigger> </Style.Triggers> </Style>
For the moment I don't know how to show the TextBox focused.
Joe, did you see my previous post? Once I apply my link style to the CellValuePresenter, then the edit style must be overridden as well. When I double-click I want it to go back to the default behavior of using a xamTextEditor.
Cool. Thanks. One more question. Now that I have overridden the CellValuePresenter style, how can get the default style back that allows me to edit again? When I double click on the cell, the style retains the textblock style instead of the default xamTextEditor.
Thanks,
Rod
Hi Rod -
Yes - you should be able to say:
Text="{Binding RelativeSource={RelativeSource TemplatedParent},Path=Value}"
Joe