SfStepProgressBar - Both 'ContentTemplate' and 'ContentTemplateSelector' are set

I am using SfStepProgressBar v27.1.51 with wpf but when I set a marker template selector, I get this warning reported in the Output window

System.Windows.Data Error: 25 : Both 'ContentTemplate' and 'ContentTemplateSelector' are set;  'ContentTemplateSelector' will be ignored. StepViewItem:'StepViewItem' (Name='')

Strangely though, it visually looks ok. What content am I setting below, other than the marker template?

<syncfusion:SfStepProgressBar x:Name="progbarStamps"
Background="Black"
   ActiveConnectorColor="{StaticResource NRMGreenBrush}"
   ConnectorColor="{StaticResource NRMGrayBrush}"
   ConnectorThickness="8"
   Margin="0,15,0,0"
   FontSize="24"
   Foreground="White"
   ItemSpacing="{Binding StampItemSpacing}"
   ItemsSource="{Binding StampStepsCollection}"
   SelectedIndex="{Binding SelectedStampIndex}"
   d:SelectedIndex="1"
   MarkerTemplateSelector="{StaticResource customStampMarkerTemplate}"
   ItemTemplateSelector="{StaticResource customStampItemTemplate}" />



15 Replies

RB Rajavignesh BalaSankar Syncfusion Team October 8, 2024 10:17 AM UTC

Hi Paul,


We tried to reproduce the reported issue with the provided code snippet, but we are unable to reproduce the issue. We have created a simple sample with the provided code snippet and attached below for your reference. Please modify the attached sample to reproduce the reported issue and share it back with us to investigate further on this issue.


Regards,

Raja Vignesh.


Attachment: WPF_ProgressBar_Sample_c4608d0a.zip


PP Paul Parkins October 8, 2024 09:10 PM UTC

Hi Raja,

Thanks for trying. It is unfortunate that the definition of the step progress bar alone was not enough. I have managed to reproduce the problem by taking your demo sample and adding my progress bar into it. from our app). However in doing so I can managed to identify the cause of the problem....

If you take your sample project and look at the constructor of the window, in the "code behind" you will see this

        public MainWindow()

        {
            InitializeComponent();
            progbarStamps.ItemTemplateSelector = new DataTemplateSelector();
        }

If you now comment out the like that defines the ItemTemplateSelector and then run the application, you will see exactly the warning I reported, in the output window.

To resolve the issue in my own application (FYI, a mainly VB solution), I simply had to add a constructor that initialised both of my template selector properties.

    Public Sub New()
        ' This call is required by the designer.
        InitializeComponent()

        ' Add any initialization after the InitializeComponent() call.
        progbarStamps.ItemTemplateSelector = New DataTemplateSelector
        progbarStamps.MarkerTemplateSelector = New DataTemplateSelector
    End Sub

Quite why they have to be initialised, before they could be referred to in xaml (without resulting in the "duplicate content selectors" warning) , only you can answer. Although I did look at the original demo's step progess bar code behind before implenmeting my own progress bar, I didn't spot this important initialisation step!

If you were to check the Customizing Data Template SfStepProgressBar documentation page like I did, you can see that the C# section of neither "Item" nor "Marker" template selections mentions this initialisation step. If you agree, this documentation page needs updating.


Thanks for your help, though maybe I helped you too? You may close this support ticket.






PP Paul Parkins October 9, 2024 02:47 PM UTC

Hi, me again.

Whilst I thought all was ok and said you could close the ticket, actually something still isn't right....

On startup my markers do not display and some text is displayed instead of my items

Image_1598_1728484090098

At no point is the code in my 2 selectors hit. It would seem that the template selectors have not been set, despite being defined in the xaml.


At runtime if I cut these 2 lines from my progress bar's xaml, and then re-paste them, then my selector code is hit, and the markers and items display fine (though it does not show the active item if I do this).

Image_1088_1728484274014

 So it is only working as I expect, if I define these 2 properties at runtime and not design time.

My progress bar is defined at design time to use my 2 selectors 

<syncfusion:SfStepProgressBar x:Name="progbarStamps"
Background="Black"
ActiveConnectorColor="{StaticResource NRMGreenBrush}"
ConnectorColor="{StaticResource NRMGrayBrush}"
ConnectorThickness="8"
Margin="0,15,0,0"
FontSize="24"
Foreground="White"
ItemSpacing="{Binding StampItemSpacing}"
ItemsSource="{Binding StampStepsCollection}"
SelectedIndex="{Binding SelectedStampIndex}"
MarkerTemplateSelector="{StaticResource customStampMarkerTemplate}"
ItemTemplateSelector="{StaticResource customStampItemTemplate}" />


Those selector resources are defined in my control's resources section

  xmlns:selectors="clr-namespace:FrontEnd.TemplateSelectors"

    <UserControl.Resources>
        <selectors:NRMStampMarkerTemplateSelector x:Key="customStampMarkerTemplate" />
        <selectors:NRMStampItemTemplateSelector x:Key="customStampItemTemplate" />

and my 2 selectors are in non-code behind files in a TemplateSelectors namespace.

The compiler is happy with everything at designtime. It just doesn't work first time, at runtime.


Any ideas on this?  I will try to modify your sample to contain my progress bar this evening, in an effort to replicate what is happening


UPDATE:  It seems to be my "fix" yesterday causing this.... the setting of the 2 template selector properties during the window's constructor.  So it seems I can it displaying fine with the original warning (see title), or eliminate the warning but not have it display fine.  The Syncfusion demo I referred to was doing something so,ilr in it's constructor. So do I do this or not?  Can you recommend a technique to both eliminate the warning AND display fine first time?




KG Krithika Ganesan Syncfusion Team October 10, 2024 02:24 PM UTC

We were unable to reproduce the reported issue with the provided details. For your reference, we have attached a sample that we used to attempt reproducing the issue on our end. If the issue persists on your side, please modify the sample accordingly and share it with us. This will help us investigate further.


Attachment: ProgressBarSample_a43a750a.zip


PP Paul Parkins October 11, 2024 12:18 PM UTC

No your sample demonstrates the issue fine, if you include or comment out the correct bits.

I have attached your project back, with some bits you commented out, put back in. This is the state I believed my app should be in after following the demo project on progress bar customisation. With the project as I am supplying it back:

  • The progress looks like this (where is the text?)
Image_4973_1728648795591
  • The output window shows the original problem I reported
Image_8167_1728648807156

Then if you uncomment these lines in the window constructor and run again Image_4010_1728648845246

you will find the progress bar now looks like this on startup

Image_2249_1728648881764

but if you temporily cut these 2 lines from the progress xaml and save it,

Image_3936_1728649003599


then paste them back in and save it again then the progress looks like this

Image_9870_1728648967848


So

  1. With the initialisation in the constructor, I get the warnings I originally reported
  2. With the intialisation (as copied from one of your master demos), then it visually does not look right



Attachment: WPF_ProgressSample_2_592b957d.zip


KG Krithika Ganesan Syncfusion Team October 14, 2024 02:54 PM UTC

We have been able to reproduce the reported issue where setting the template selector of SFStepProgressBar in XAML is not functioning as expected. We are currently analyzing the issue and will provide further updates by October 16, 2024.



KG Krithika Ganesan Syncfusion Team October 16, 2024 03:56 PM UTC

We need additional time to analyze this issue, we will provide more information on October 18th, 2024.



RB Rajavignesh BalaSankar Syncfusion Team October 21, 2024 02:27 PM UTC

On analyzing the provided sample, we found that you have set the template for the items by overriding the `SelectTemplate` method. Due to that the tick mark and wrong mark occurred instead of text. If you remove the template set to the stepView item, the text will be appeared properly. We have also modified the sample for your reference and attached below. The error message also removed with the sample changes.


Attachment: WPF_ProgressSample_2_f931f5df.zip


PP Paul Parkins October 22, 2024 08:19 AM UTC

Hi. Thanks. I took you sample and ran it, and it looks like this Image_3690_1729584099788 How can that be right?


You are quite correct in that I had set the template by overriding the '"SelectTemplate' method. I did this because I was learning by example by duplicating what you Syncfusion had done in your  own StepProgressBatCustomization.xaml.cs file which is part of your Syncfusion Sample Browser WPF_60.


So I am not really understanding what you think I did wrong, compared to your own demo, and since your latest demo doesn't look like what you intended, then I don't think you have found a resolution either.


When I look at your latest sampleabove, I see you have left in SelectTemplate, but you have commented out all the step status to template resource logic. In which case, how would your version of the sample ever apply different templates?Image_5009_1729584937144


REgards


Paul





PP Paul Parkins October 23, 2024 09:32 AM UTC

I note the C# code within "Customizing Data Templates" in your online documentation, also shows to override SelectTemplate(). 

Image_2039_1729675801525



REaltedI am now receiving reports of occassional exceptions "No target was specified for 'System.Windows.Media.Animation.DoubleAnimation'.  This seems to be coming from here Image_3043_1729675919772

Is it possible to disable the animation?



RB Rajavignesh BalaSankar Syncfusion Team October 23, 2024 11:51 AM UTC

Paul, You can override the custom templates in the `SelectTemplate` method. But previously, you have enquired about why the text content is not visible when setting the templates from xaml side. As you have override the Default templates of the progress bar in the `SelectTemplate` method, the modified templates that was set in the XAML side was updated instead of the default text template. Please refer the below snap for the custom templates present in the Xaml side of the sample.

Previously, In C# side you have created a new instance of DataTempleSelector for the `MarkerTemplateSelector` and `ItemTemplateSelector`. In XAML side, you have created the instance of the StepViewItemTemplateSelector which you have inherited from the DataTemplateSelector. This causes the difference while setting the two template selectors using XAML and C#. Please refer the below snapshot for the same.

In C# side, if you create a new instance of `StepViewItemTemplateSelector` for the two template selectors instead of `DataTemplateSelector`, both the results will be same. So, if you remove the `SelectTemplate` method from your sample, you will get the default text template on the result or else the custom template will be applied.


Regarding the animation issue reported, we have tried with the provided sample to reproduce the reported issue, and it was not reproduced on our end. We request you to kindly modify the sample that was shared in our previous update to reproduce the issue and share it back with us along with the detailed replication steps to proceed further on this.



PP Paul Parkins October 23, 2024 04:08 PM UTC

Hi.

Thanks for your detailed explanation, I am understanding what you say.

I think I have complicated this whole ticket, by proposing my own solution which I applied incorrectly. The ticket has then gone toward correcting that sample, and answering subsequent minor queries, based on the feedback of that. 


Whilst I do feel my understanding is in line with yours, my original problem reported in this ticket still applies in my actual application...

From my actual app, I have 2 selectors in xaml Image_8428_1729699127315

which are used by my progress bar Image_8811_1729699162546

instances of which are created in the constructor Image_2894_1729699202709

and are implemented as you have seen before Image_1244_1729699249797


As originally stated, this issue were warnings being emitted which I didn't understand, and which were disconcerting. I am now having other issues with the step progress bar too, and perhaps they are related. For example:

  • Marker bar does not always light up to the active step
  • Does not always show selected step when SelectedIndex set after dynamically loading the progress bar
  • Occasional animation exceptions from the component (reported to me but not experienced myself)


I think I need to take the time to implement a much better sample based on what I am doing (contents of the progress bar are dynamic), which exhibits any and all issues I still encounter. I also think it would be clearer to raise a new ticket based on this.

Thanks again  Rajavignesh





RB Rajavignesh BalaSankar Syncfusion Team October 24, 2024 03:48 PM UTC

We will wait for the sample that you plan to share. 



PP Paul Parkins October 24, 2024 05:39 PM UTC

I  started that project but to demonstrate the use of multiple dynamically loaded "stampcards" represented by a single step progress bar, I decided this was far too complicated for a "sample" application.

In the meantime I have found a bug in my own code, and now the step & marker selection does seem ok, so I am hopeful that might also fix the animation issue related to selecting a step.  

Thanks for your continued interest and help


Paul



KG Krithika Ganesan Syncfusion Team October 25, 2024 10:23 AM UTC

We will await the sample you plan to share with us to help reproduce the issues you are experiencing on your end.


Loader.
Up arrow icon