We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

AddNewRow customization

Hi,

I'm starting to practice with Syncfusion controls developing a simple WPF MVVM app.

Is there a way to customize the "click here to add a new row" label appearing in the new row placeholder? 

I would like to translate it in italian.

Thanks

Giacomo


5 Replies

SV Srinivasan Vasu Syncfusion Team July 12, 2017 04:55 AM UTC

Hi Giacomo, 
 
Thanks for contacting Syncfusion support. 
 
We have checked your query and you can achieve your requirement by customizing the style of AddNewRowControl and change content of ContentPresenter. 
 
Please refer the below code 
 
<Style TargetType="syncfusion:AddNewRowControl"> 
 
            <Setter Property="Foreground" Value="White" /> 
 
            <Setter Property="BorderBrush" Value="Gray" /> 
 
            <Setter Property="BorderThickness" Value="0" /> 
 
            <Setter Property="Template"> 
                <Setter.Value> 
                    <ControlTemplate TargetType="syncfusion:AddNewRowControl"> 
                        <Grid> 
                            <VisualStateManager.VisualStateGroups> 
                                <VisualStateGroup x:Name="AddNewRowStates"> 
                                    <VisualState x:Name="Normal" /> 
                                    <VisualState x:Name="Edit"> 
                                        <Storyboard> 
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="PART_AddNewRowTextBorder" Storyboard.TargetProperty="(UIElement.Visibility)"> 
                                                <DiscreteObjectKeyFrame KeyTime="0"> 
                                                    <DiscreteObjectKeyFrame.Value> 
                                                        <Visibility>Collapsed</Visibility> 
                                                    </DiscreteObjectKeyFrame.Value> 
                                                </DiscreteObjectKeyFrame> 
                                            </ObjectAnimationUsingKeyFrames> 
                                        </Storyboard> 
                                    </VisualState> 
                                </VisualStateGroup> 
 
                                <VisualStateGroup x:Name="BorderStates"> 
                                    <VisualState x:Name="NormalRow" /> 
 
                                    <VisualState x:Name="FooterRow"> 
                                        <Storyboard BeginTime="0"> 
                                            <ThicknessAnimationUsingKeyFrames BeginTime="0" 
                                                                          Duration="1" 
                                                                          Storyboard.TargetName="PART_AddNewRowBorder" 
                                                                          Storyboard.TargetProperty="BorderThickness"> 
                                                <EasingThicknessKeyFrame KeyTime="0" Value="0, 1, 0, 0" /> 
                                            </ThicknessAnimationUsingKeyFrames> 
                                            <ThicknessAnimationUsingKeyFrames BeginTime="0" 
                                                                          Duration="1" 
                                                                          Storyboard.TargetName="PART_AddNewRowBorder" 
                                                                          Storyboard.TargetProperty="Margin"> 
                                                <EasingThicknessKeyFrame KeyTime="0" Value="0, -1, 0, 0" /> 
                                            </ThicknessAnimationUsingKeyFrames> 
                                        </Storyboard> 
                                    </VisualState> 
                                </VisualStateGroup> 
                            </VisualStateManager.VisualStateGroups> 
 
                            <Rectangle x:Name="PART_CurrentFocusRow" 
                                   Margin="2,2,0,2" 
                                   HorizontalAlignment="Right" 
                                   Stroke="DarkGray" 
                                   StrokeDashArray="2,2" 
                                   StrokeThickness="1" 
                                   Visibility="{TemplateBinding CurrentFocusRowVisibility}" /> 
 
                            <Border Background="{TemplateBinding RowSelectionBrush}" 
                                Clip="{TemplateBinding SelectionBorderClipRect}" 
                                Visibility="{TemplateBinding SelectionBorderVisiblity}" /> 
                            <Border x:Name="PART_AddNewRowBorder" 
                                Background="{TemplateBinding Background}" 
                                BorderBrush="{TemplateBinding BorderBrush}" 
                                BorderThickness="{TemplateBinding BorderThickness}"> 
                                <ContentPresenter /> 
                            </Border> 
 
                            <Border x:Name="PART_AddNewRowTextBorder" 
                                Background="#FFE5E5E5" 
                                BorderBrush="Transparent" 
                                BorderThickness="0,0,1,1" 
                                Clip="{TemplateBinding TextBorderClip}" 
                                IsHitTestVisible="False"> 
                                <ContentPresenter Margin="{TemplateBinding TextMargin}" 
                                              HorizontalAlignment="Left" 
                                              VerticalAlignment="Center" 
                                              Content="Add New Row" /> 
                            </Border> 
 
                        </Grid> 
                    </ControlTemplate> 
                </Setter.Value> 
            </Setter> 
        </Style> 
 
 
Please refer the below UG Link: 
 
 
Also, SfDataGrid enables you to customize the watermark text of AddNewRow by changing value of AddNewRowText in Resource Designer. To customize the AddNewRowText, add the default Syncfusion.SfDataGrid.WPF.resx file in Resources folder and then customize the value of AddNewRowText. 
 
 
 
Regards, 
Srinivasan 



UN Unknown Syncfusion Team July 12, 2017 07:19 AM UTC

Hi Srinivasan,

thank you for your reply.

Apologize if I could find the solution in your documentation without direct support, I will learn to better read it soon.

I am trying the second way because I find it more proper and elegant than customize the style for a single label but I am not achieving my goal.

Here are my steps:

  • I downloaded the default SfDataGrid resx file 
  • I added it to my project as a resource, finding it in the Resources folder in Solution Explorer
  • I opened it and edited the value of the "AddNewRowText" property, then saved it
  • I rebuild the project and ran it

but the text is still "Click here to add a new row".

I also changed the compile action setting it to "Resource" without success.

You can see all of this summarized in the attached picture

Where am I wrong?

Thanks

Giacomo


Attachment: Immagine_b6e0adfd.zip


SI Silvio July 12, 2017 09:16 AM UTC

Dear Giacomo,

I'm glad to answer you since I'm italian too, and I'm developing with this library in WPF for more than one year.

Of course I soon had your same requirement to localize in Italian the English parts of the library and probably had your same problems.

Probably this little article can help you:

https://www.syncfusion.com/kb/5962/how-to-localize-when-resource-file-present-in-different-assembly-or-default-namespace-is-not-same-as


In addition, I show you in the attached zip file how I have solved the problem in my application.

I added a directory named "Resources" in the Assembly that manages my views and inserted in it two resource files that I probably changed more than one year ago, and it works.

See the attached zip file. Hope it can help you.

Ciao e buon lavoro !!!!

Io mi trovo molto bene con l'utilizzo di queste librerie.


Silvio Scattaglia, Infolab Piacenza



Attachment: localizzazione_syncfusion_2fc1a864.zip


UN Unknown Syncfusion Team July 13, 2017 08:14 AM UTC

Ciao Silvio,

it's nice to find you here!

Thanks for your help, I solved the problem: it was for I added the .resx file as a project resource rather than manually adding a "Resources" folder in solution explorer and then add into it the .resx file.

Now it works perfectly!

Thanks again, read you soon!

Giacomo



SV Srinivasan Vasu Syncfusion Team July 13, 2017 05:12 PM UTC

Hi Giacomo, 
 
As stated by Silvio, you can localize the file present in different assembly or default namespace is not as same as assembly name by using Kb.

 
Thank for your update Mr.Silvio and Giacomo. 
 
Regards,
Srinivasan 


Loader.
Up arrow icon