Dear Telerik team,
We have a RadGridView with localised columns and we would like to use string that remain same for all localised value. In order to achieve we use UniqueName="Id" and Set AutomationProperties.AutomationId="{Binding UniqueName, RelativeSource={RelativeSource Self}}" but when we run application the Header which is a localised string always get precedence and we end up with header value.
Here is a code there we were using for defining columns
<
telerik:GridViewDataColumn
x:Name
=
"OrderId"
Width
=
"auto"
AutomationProperties.AutomationId
=
"{Binding UniqueName, RelativeSource={RelativeSource Self}}"
DataMemberBinding
=
"{Binding Id}"
Header
=
"{x:Static resources:Resources.Id}"
Style
=
"{StaticResource RightAlignedRadGridViewColumnStyle}"
UniqueName
=
"OrderId"
>
6 Answers, 1 is accepted
Hello Usman,
Thank you for the provided code snippet.
May I ask you to elaborate a bit on the described scenario? Can you share what you mean by "when we run application the Header which is a localised string always get precedence and we end up with header value."? Where is the header value applied? Can you share some sample pictures demonstrating the observed on your end result and elaborate on what is the desired behavior? This will hopefully allow me to better understand the scenario and think of an appropriate suggestion.
I am looking forward to your reply.
Regards,
Vladimir Stoyanov
Progress Telerik

Hi Vladimir,
Thanks for your response,
"when we run application the Header which is a localised string always get precedence and we end up with header value."
Localised string is used in application using resources for Header property of telerik:GridViewDataColumn as I shared already in the code snippet above.
You can also observe that AutomationId is binded to UniqueName and unique name has also been defined.
The resultant binded value which is localised string is displayed.
I am attaching two snapshots
MainWindow displaying the header with localised string
LiveProperties displaying the AutomationId.
Do let me know if you need more info.
Hi Usman,
If I correctly understood your requirement, you wish to have the UniqueName of the column (OrderId) as the AutomationId of the GridViewHeaderCell while still displaying the localized string as the Header (Reihenfolge). Please correct me if I'm wrong in this assumption.
If this is indeed the case, please note that the header cells will not acquire the AutomationId of their parent column automatically. You need to do this manually by creating the following style for these elements:
<Style TargetType="telerik:GridViewHeaderCell">
<Setter Property="AutomationProperties.AutomationId" Value="{Binding Column.UniqueName, RelativeSource={RelativeSource Self}}" />
</Style>
Please have a look and let me know if a similar approach would work at your end.
Regards,
Dilyan Traykov
Progress Telerik

Hi Dilyan,
Yes, your assumption is right.
Your suggested style does resolve required problem but the actual issue was that name property of column (x:Name) also get changed as per the header title which in my opinion it shouldn't.
Can you please help me understand if I am thinking the otherway?
Hi Usman,
Even though the GridViewColumn element inherits from FrameworkContentElement (thus inheriting the Name property) it is not actually used by the column.
Can you please specify why you need to use the Name property and not the UniqueName and/or DataMemberBinding.Path.Path properties which will return the name of the bound source property instead?
Regards,
Dilyan Traykov
Progress Telerik

Hi Dilyan,
Your suggested style already helped in achieving desired behaviour but as we usually used the name of control and bind them to automation id but in case of GridView Columns the name of control changes based on header value and I was just curious about this behaviour.
Thanks for your help.