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

Trying to create a listbox filled with a collection of times that can be changed using the sfTimePicker.

I'm trying to create a list box filled with some sfTimePicker objects which creates a user editable time schedule but I'm having a few problems.

This is the XML snippet
            <ListBox x:Name="listBox" Height="200"  ScrollViewer.VerticalScrollBarVisibility="Visible"  >
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <chart:SfTimePicker HorizontalAlignment="Left" Width="200"  SelectorFormatString="hh:mm tt" >
                        <chart:SfTimePicker.SelectorStyle>
                             <Style TargetType="chart:SfTimeSelector">
                                <Setter Property="Header" Value="Set measurement time"/>
                                <Setter Property="MinuteInterval" Value="15"  />
                            </Style>
                        </chart:SfTimePicker.SelectorStyle>
                      </chart:SfTimePicker>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>

This is the code behind
    public partial class TimeList : UserControl
    {
        public ObservableCollection<SfTimePicker> TimesList{ get; set; }

        public TimeList()
        {
            InitializeComponent();

            TimesList = new ObservableCollection<SfTimePicker>();

            SfTimePicker picker;
            picker = new SfTimePicker();
            picker.Value = new TimeSpan(10, 00, 00);
            TimesList.Add(picker);

            picker = new SfTimePicker();
            picker.Value = new TimeSpan(10, 15, 00);
            TimesList.Add(picker);

            listBox.ItemsSource = TimesList;
        }
    }

The issues are:-
1) When I click on the time object in the list the popup is displayed but the the time is shown as 24 hours even though I set the SelectorFormatString="hh:mm tt",
the selector property changes for the header text and minute interval works OK.

2) In the code behind I populate the list of times using different fixed times using TimeSpan() but the displayed values always show the current time of the PC, its as though the list is correctly showing the number of time objects but ignoring the values.

Any help much appreciated
Mark





14 Replies

JP Jagadeesan Pichaimuthu Syncfusion Team February 7, 2019 12:13 PM UTC

Hi Mark, 
 
Thanks for contacting Syncfusion support.  
 
Query 1: Displayed values always show the current time of the PC, it’s as though the list is correctly showing the number of time objects but ignoring the values. 
 
We have modified the provided sample based on your requirement in which we have set the TimeSpan collection to ItemsSource property of ListBox instead of SfTimePicker collection and bind it to the SfTimePicker Value property. Please find the code snippet, screenshot and sample for the same from the below location.  
 
XAML:  
 
<ListBox x:Name="listBox"  Height="200"  ScrollViewer.VerticalScrollBarVisibility="Visible"  > 
    <ListBox.ItemTemplate> 
        <DataTemplate> 
             <input:SfTimePicker HorizontalAlignment="Left" Width="200" Name="timePicker" Value="{Binding }" FormatString="hh:mm:ss" SelectorFormatString="hh:mm tt"> 
                  <input:SfTimePicker.SelectorStyle> 
                      <Style TargetType="input:SfTimeSelector"> 
                          <Setter Property="Header" Value="Set measurement time"/> 
                          <Setter Property="MinuteInterval" Value="15"  /> 
                      </Style> 
                  </input:SfTimePicker.SelectorStyle> 
              </input:SfTimePicker> 
        </DataTemplate> 
    </ListBox.ItemTemplate> 
</ListBox> 
 
C#: 
 
public ObservableCollection<TimeSpan> TimesList { get; set; } 
 
public MainWindow() 
{ 
   InitializeComponent(); 
 
   TimesList = new ObservableCollection<TimeSpan>(); 
 
   TimeSpan picker; 
   picker = new TimeSpan(10, 00, 00); 
   TimesList.Add(picker); 
 
   picker = new TimeSpan(10, 15, 00);  
   TimesList.Add(picker); 
 
   listBox.ItemsSource = TimesList; 
}       
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Please try this above solution and let us know if it is helpful.  
 
Query 2:  Time is shown as 24 hours even though I set the SelectorFormatString="hh:mm tt" 
 
We have checked your query “Time is shown as 24 hours even after setting the SelectorFormatString as “hh:mm tt” in SfTimePicker”, but we were unable to reproduce the reported behavior in our side. Please find the video which we have used to reproduce the reported issue below and let us know whether we missed any scenario in replicating the issue. 
 
 
If we misunderstood your requirement, please provide more information regarding the requirement or video / screenshot of SfTimePicker which shows the incorrect 24 format. This would help us to proceed further. 
     
Regards, 
Jagadeesan 



MA Mark February 7, 2019 04:40 PM UTC

Thanks for your response, the list box is working a treat but the popup time picker will still only show a 24 hour selection i.e. no AM/PM.

I looked at your video and its exactly how i would have expected mine to work with  SelectorFormatString="hh:mm tt but it does not.

I created a new project with has the same problem so its either something I'm missing in the project or something to do with my environment.

I running an up to date version or Windows 10 professional and I'm using the community edition of visual studio 2017.

I have attached my test project.

Mark

Attachment: TimePicker_f72c7e0d.zip


MA Mark February 7, 2019 05:28 PM UTC

Further to my last reply I have added a time picker outside the list box and its works as expected so its as though its something to do with being in a list box!

Ave attached my update file set and two .bmp's showing the two different outcomes.

Mark

Attachment: TimePicker_da954699.zip


MA Mark February 7, 2019 05:30 PM UTC

Forgot the bmp's

Attachment: Pictures_fead17ad.zip


JP Jagadeesan Pichaimuthu Syncfusion Team February 8, 2019 09:24 AM UTC

Hi Mark, 
 
Thanks for using Syncfusion product. 
 
We have confirmed that the reported issue “SelectorFormatString property not working properly in SfTimePicker while setting it as DataTemplate of ListBox” is a defect. We will provide the fix for the same in 16.4.0.42 version on February 15th, 2019.  
 
We appreciate your patience until then. 
 
Regards, 
Jagadeesan 



MA Mark February 8, 2019 09:27 AM UTC

That's great news I will await the fix

Regards Mark


JP Jagadeesan Pichaimuthu Syncfusion Team February 8, 2019 11:18 AM UTC

Hi Mark, 

As we updated earlier we will fix this issue and provide you the patch on February 15th, 2019. 

Regards, 
Jagadeesan 



MA Mark February 12, 2019 01:47 PM UTC

You have been very helpful in solving my issues of the listbox full of times which works very well, the problem I have now is whenever the user selects and changes the time in the list box, what is needed to then get the itemssource observablecollection updated to correspond to the new edited time?

Thanks Mark


SM Subashini Mahendran Syncfusion Team February 13, 2019 04:29 PM UTC

Hi Mark, 
 
Thanks for your update. 
 
We have checked your query “How to the update the ListBox ItemsSource observablecollection correspond to the new edited time in SfTimePicker”. We have prepared a sample based on your requirement in which we have updated ListBox ItemsSource collection when new value edited in SfTimePicker by using its ValueChanged event and shown the updated ItemsSource values in other ListBox through a button click. Please find the video and sample for the same from the below location.  
 
 
If we misunderstood your requirement, please provide more information regarding the requirement. This would help us to proceed further. 
 
Regards,  
Subashini M. 



JP Jagadeesan Pichaimuthu Syncfusion Team February 15, 2019 07:33 AM UTC

Hi Mark, 
 
Thanks for your patience. 
 
The reported issue “SelectorFormatString property not working properly in SfTimePicker while setting it as DataTemplate of ListBox has been fixed and the patch can be download from the below links.  
  
Recommended approach - exe will perform automatic configuration.  
          
Please find the patch setup from below location:  
  
Patch link :    
 
Please find the patch assemblies alone from below location:  
  
Assemblies Link:   
  
Nuget link:   

 
 
Assembly Version: 16.4.0.42 
          
Installation Directions:  
This patch should replace the files "Syncfusion.SfInput.WPF” under the following folder.      
$system drive:\ Files\Syncfusion\Essential Studio\$Version # \precompiledassemblies\$Version#\[TargetFramework]            
Eg : $system drive:\Program Files\Syncfusion\Essential Studio\16.4.0.42\precompiledassemblies\16.4.0.42\4.6  
        
To automatically run the Assembly Manager, please check the Run assembly manager checkbox option while installing the patch. If this option is unchecked, the patch will replace the assemblies in precompiled assemblies’ folder only. Then, you must manually copy and paste them to the preferred location or you must run the Syncfusion Assembly Manager application (available from the Syncfusion Dashboard, installed as a shortcut in the Application menu) to re-install assemblies.           
  
  
Disclaimer:      
Please note that we have created this patch for version 16.4.0.42 specifically to resolve the issue reported in the forum 142501. If you have received other patches for the same version for other products, please apply all patches in the order received.   
 
This fix will be included in our upcoming Volume 1, 2019 release.  
 
Regards, 
Jagadeesan


MA Mark February 15, 2019 09:24 AM UTC

Hi,

Thanks for the patches but I just noticed that the patches are for version 16.4.0.42 but I'm using your lasted release which is 16.4.0.52, do you have the same patch for this version?

Regards Mark


JP Jagadeesan Pichaimuthu Syncfusion Team February 15, 2019 11:16 AM UTC

Hi Mark, 
 
Thanks for your update. 
 
As per your request, we have merged the fix in 16.4.0.52 version and please find the patch from below 
  
Recommended approach - exe will perform automatic configuration.  
          
Please find the patch setup from below location:  
  
Patch link :    
 
Please find the patch assemblies alone from below location:  
  
Assemblies Link:   
  
Nuget link:   

 
 
Assembly Version: 16.4.0.52 
          
Installation Directions:  
This patch should replace the files "Syncfusion.SfInput.WPF” under the following folder.      
$system drive:\ Files\Syncfusion\Essential Studio\$Version # \precompiledassemblies\$Version#\[TargetFramework]            
Eg : $system drive:\Program Files\Syncfusion\Essential Studio\16.4.0.52\precompiledassemblies\16.4.0.52\4.6  
        
To automatically run the Assembly Manager, please check the Run assembly manager checkbox option while installing the patch. If this option is unchecked, the patch will replace the assemblies in precompiled assemblies’ folder only. Then, you must manually copy and paste them to the preferred location or you must run the Syncfusion Assembly Manager application (available from the Syncfusion Dashboard, installed as a shortcut in the Application menu) to re-install assemblies.           
  
  
Disclaimer:      
Please note that we have created this patch for version 16.4.0.52 specifically to resolve the issue reported in the forum 142501. If you have received other patches for the same version for other products, please apply all patches in the order received.   
 
This fix will be included in our upcoming Volume 1, 2019 release.  
 
Regards, 
Jagadeesan 



MA Mark February 15, 2019 11:37 AM UTC

Sorry to be a pain, but when I try to download the 16.4.0.52 patch it says I'm not authorised to do so, the 16.4.0.42 download OK

Mark


SM Subashini Mahendran Syncfusion Team February 18, 2019 01:12 PM UTC

Hi Mark, 
 
Sorry for inconvenience caused. The reported problem arises due to mismatch of customer id in previously updated patch. Now, we have started patch with correct id and please find the same from below 
  
Recommended approach - exe will perform automatic configuration.  
          
Please find the patch setup from below location:  
  
Patch link :    
 
Please find the patch assemblies alone from below location:  
  
Assemblies Link:   
  
Nuget link:   

 
 
Assembly Version: 16.4.0.52 
          
Installation Directions:  
This patch should replace the files "Syncfusion.SfInput.WPF” under the following folder.      
$system drive:\ Files\Syncfusion\Essential Studio\$Version # \precompiledassemblies\$Version#\[TargetFramework]            
Eg : $system drive:\Program Files\Syncfusion\Essential Studio\16.4.0.52\precompiledassemblies\16.4.0.52\4.6  
        
To automatically run the Assembly Manager, please check the Run assembly manager checkbox option while installing the patch. If this option is unchecked, the patch will replace the assemblies in precompiled assemblies’ folder only. Then, you must manually copy and paste them to the preferred location or you must run the Syncfusion Assembly Manager application (available from the Syncfusion Dashboard, installed as a shortcut in the Application menu) to re-install assemblies.           
  
  
Disclaimer:      
Please note that we have created this patch for version 16.4.0.52 specifically to resolve the issue reported in the forum 142501. If you have received other patches for the same version for other products, please apply all patches in the order received.   
 
This fix will be included in our upcoming Volume 1, 2019 release.  
  
Regards, 
Subashini M. 
 


Loader.
Live Chat Icon For mobile
Up arrow icon