Hello, im getting this error """NaN" ist not a valid value for property MaxHeight"
when i close the appointment editor from syncfusion, and change to other page of my app with other collection of items.
Scheduler view:
<UserControl x:Class="DrMedOffice.Views.SchedulerView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:syncfusion="http://schemas.syncfusion.com/wpf"
xmlns:viewmodels="clr-namespace:DrMedOffice.ViewModels"
xmlns:converter="clr-namespace:DrMedOffice.Converter"
xmlns:cm="http://caliburnmicro.com"
d:DataContext="{d:DesignInstance Type=viewmodels:SchedulerViewModel}"
mc:Ignorable="d"
Background="White">
<UserControl.Resources>
<converter:RechnungsStatusConverter x:Key="RechnungsStatusConverter" />
</UserControl.Resources>
<Grid Margin="10">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Border
Grid.Row="0"
BorderBrush="LightGray"
BorderThickness="0,0,0,1px">
<Label Foreground="Green" Content="Termine" />
</Border>
<StackPanel Grid.Row="1" Grid.Column="0" Orientation="Horizontal" HorizontalAlignment="Left" >
<Button BorderThickness="0"
cm:Message.Attach="[Event Click] = [Action OnNewItemClicked($source, $eventArgs)]"
Margin="0,3,3,3">Neuen Termin
</Button>
<Button BorderThickness="0"
cm:Message.Attach="[Event Click] = [Action OnEditItemClicked($source, $eventArgs)]"
IsEnabled="{Binding ItemIsSelected}"
Margin="0,3,3,3">Termin Ändern
</Button>
<Button BorderThickness="0"
cm:Message.Attach="[Event Click] = [Action OnDeleteItemClicked($source, $eventArgs)]"
IsEnabled="{Binding ItemIsSelected}"
Margin="0,3,3,3">Termin löschen
</Button>
</StackPanel>
<StackPanel Grid.Row="1" Grid.Column="1" Orientation="Horizontal" HorizontalAlignment="Right">
<Button BorderThickness="0"
cm:Message.Attach="[Event Click] = [Action ChangeSchedulerViewTypeClicked('Day')]"
Margin="0,3,3,3">Tag
</Button>
<Button BorderThickness="0"
cm:Message.Attach="[Event Click] = [Action ChangeSchedulerViewTypeClicked('Week')]"
Margin="0,3,3,3">Woche
</Button>
<Button BorderThickness="0"
cm:Message.Attach="[Event Click] = [Action ChangeSchedulerViewTypeClicked('Month')]"
Margin="0,3,3,3">Monat
</Button>
</StackPanel>
<syncfusion:SfScheduler x:Name="Schedule" Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="2"
ItemsSource="{Binding Items}"
AllowViewNavigation="True"
ViewType="{Binding SchedulerViewType}">
<syncfusion:SfScheduler.DaysViewSettings>
<syncfusion:DaysViewSettings MinimumAppointmentDuration="0:30:0" />
</syncfusion:SfScheduler.DaysViewSettings>
<syncfusion:SfScheduler.MonthViewSettings>
<syncfusion:MonthViewSettings AppointmentDisplayMode="Appointment"
AppointmentDisplayCount="1"/>
</syncfusion:SfScheduler.MonthViewSettings>
<syncfusion:SfScheduler.AppointmentMapping>
<syncfusion:AppointmentMapping
Subject="Subject"
StartTime="StartTime"
EndTime="EndTime"
AppointmentBackground="AppointmentBackground"
Foreground="Foreground"/>
</syncfusion:SfScheduler.AppointmentMapping>
<syncfusion:SfScheduler.CellContextMenu>
<ContextMenu>
<MenuItem
Command="{Binding Source={x:Static Member=syncfusion:SchedulerCommands.Add}}" CommandParameter ="{Binding}" CommandTarget="{Binding ElementName=Schedule}" Header="Add">
<MenuItem.Icon>
<Path x:Name="AddNew" Data="{StaticResource addNew}"
Fill="#FF5A5A5B"
Width="16"
Height="16"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Stretch="Fill" />
</MenuItem.Icon>
</MenuItem>
</ContextMenu>
</syncfusion:SfScheduler.CellContextMenu>
<syncfusion:SfScheduler.AppointmentContextMenu>
<ContextMenu>
<MenuItem Command="{Binding Source={x:Static Member=syncfusion:SchedulerCommands.Edit}}"
CommandParameter ="{Binding}" CommandTarget="{Binding ElementName=Schedule}"
Header="Edit">
<MenuItem.Icon>
<Path x:Name="Edit" Data="{StaticResource edit}"
Fill="#FF5A5A5B"
Width="16"
Height="16"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Stretch="Fill"/>
</MenuItem.Icon>
</MenuItem>
<MenuItem Command="{Binding Source={x:Static Member=syncfusion:SchedulerCommands.Delete}}"
CommandParameter ="{Binding}"
Header="Delete">
<MenuItem.Icon>
<Path x:Name="Delete" Data="{StaticResource delete}"
Fill="#FF5A5A5B"
Width="16"
Height="16"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Stretch="Fill"/>
</MenuItem.Icon>
</MenuItem>
</ContextMenu>
</syncfusion:SfScheduler.AppointmentContextMenu>
</syncfusion:SfScheduler>
</Grid>
</Grid>
</UserControl>
codebehind:
public partial class SchedulerView : UserControl
{
public SchedulerView()
{
InitializeComponent();
Schedule.AppointmentEditorOpening += Schedule_AppointmentEditorOpening;
}
private void Schedule_AppointmentEditorOpening(object sender, AppointmentEditorOpeningEventArgs e)
{
e.AppointmentEditorOptions = AppointmentEditorOptions.All |
(~AppointmentEditorOptions.Background
& ~AppointmentEditorOptions.Foreground
& ~AppointmentEditorOptions.Resource
& ~AppointmentEditorOptions.TimeZone
& ~AppointmentEditorOptions.Reminder
& ~AppointmentEditorOptions.Recurrence);
}
}
ViewModel:
public class SchedulerViewModel : ListViewModelBase<MyAppointment>
{
public SchedulerViewModel(IEventAggregator eventAggregator)
: base(eventAggregator, "Termine", EFontAwesomeIcon.Solid_Calendar)
{
var from = new DateTime(2022, 03, 28, 19, 24, 00);
var to = from.AddHours(2);
var appoint = new MyAppointment(1, "Johannes Meyer", from, to);
Items = new ObservableCollection<MyAppointment>() { appoint };
}
public SchedulerViewType SchedulerViewType { get; set; } = SchedulerViewType.Week;
public void ChangeSchedulerViewTypeClicked(string viewType)
{
if (Enum.TryParse(typeof(SchedulerViewType), viewType, out var result))
{
SchedulerViewType = (SchedulerViewType)result;
}
}
bei System.Windows.DependencyObject.SetValueCommon(DependencyProperty dp, Object value, PropertyMetadata metadata, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType, Boolean isInternal)bei System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value)bei System.Windows.FrameworkElement.set_MaxHeight(Double value)bei Syncfusion.UI.Xaml.Controls.DataPager.NumericButton.GetContentWidth()bei Syncfusion.UI.Xaml.Controls.DataPager.NumericButton.SetAsCurrentPage(Boolean value)bei Syncfusion.UI.Xaml.Controls.DataPager.NumericButton.OnIsCurrentPageChanged(DependencyObject sender, DependencyPropertyChangedEventArgs args)bei System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e)bei System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e)bei System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args)bei System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType)bei System.Windows.DependencyObject.SetValueCommon(DependencyProperty dp, Object value, PropertyMetadata metadata, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType, Boolean isInternal)bei System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value)bei Syncfusion.UI.Xaml.Controls.DataPager.NumericButton.set_IsCurrentPage(Boolean value)bei Syncfusion.UI.Xaml.Controls.DataPager.PageNavigationController.ShowCurrentPage(Int32 pageIndex)bei Syncfusion.UI.Xaml.Controls.DataPager.PageNavigationController.MoveToPage(Int32 pageIndex, Boolean isElipsisClicked)bei Syncfusion.UI.Xaml.Controls.DataPager.SfDataPager.MoveToPage(Int32 oldPageIndex, Int32 pageIndex)bei Syncfusion.UI.Xaml.Controls.DataPager.SfDataPager.MoveToPage(Int32 pageIndex)bei Syncfusion.UI.Xaml.Controls.DataPager.SfDataPager.MoveToFirstPage()bei Syncfusion.UI.Xaml.Controls.DataPager.SfDataPager.OnSourcePropertyChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args)bei System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e)bei System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e)bei System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args)bei System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType)bei System.Windows.DependencyObject.InvalidateProperty(DependencyProperty dp, Boolean preserveCurrentValue)bei System.Windows.Data.BindingExpression.TransferValue(Object newValue, Boolean isASubPropertyChange)bei MS.Internal.Data.PropertyPathWorker.UpdateSourceValueState(Int32 k, ICollectionView collectionView, Object newValue, Boolean isASubPropertyChange)bei MS.Internal.Data.ClrBindingWorker.OnSourcePropertyChanged(Object o, String propName)bei System.Windows.WeakEventManager.ListenerList`1.DeliverEvent(Object sender, EventArgs e, Type managerType)bei System.Windows.WeakEventManager.DeliverEventToList(Object sender, EventArgs args, ListenerList list)bei System.ComponentModel.PropertyChangedEventManager.OnPropertyChanged(Object sender, PropertyChangedEventArgs args)bei DrMedOffice.ViewModels.ListViewModelBase`1.set_Items(ObservableCollection`1 value) in D:\Dev\DrMedOffice\DrMedOffice\DrMedOffice\ViewModels\ListViewModelBase.cs: Zeile23bei DrMedOffice.ViewModels.PatientViewModel.d__4.MoveNext() in D:\Dev\DrMedOffice\DrMedOffice\DrMedOffice\ViewModels\PatientViewModel.cs: Zeile43 bei System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()bei System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)bei System.Runtime.CompilerServices.TaskAwaiter.GetResult()bei DrMedOffice.ViewModels.ViewModelBase.d__29.MoveNext() in D:\Dev\DrMedOffice\DrMedOffice\DrMedOffice\ViewModels\ViewModelBase.cs: Zeile49 bei System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()bei System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)bei System.Runtime.CompilerServices.TaskAwaiter.GetResult()bei DrMedOffice.ViewModels.NavigationViewModel.d__13.MoveNext() in D:\Dev\DrMedOffice\DrMedOffice\DrMedOffice\ViewModels\NavigationViewModel.cs: Zeile84 bei System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()bei System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)bei System.Runtime.CompilerServices.TaskAwaiter.GetResult()bei DrMedOffice.ViewModels.NavigationViewModel.d__11.MoveNext() in D:\Dev\DrMedOffice\DrMedOffice\DrMedOffice\ViewModels\NavigationViewModel.cs: Zeile66
If you need more Informations, please ask :)
Thanks for your help
any help would be great.
Hi Johannes,
#Regarding Exception in closing the Appintment Editor
we could not replicate the reported scenario from our side. We have prepared the sample as per the given information and checked the sample from our end. We have attached the tested sample in the following link for your reference.
Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/SchedulerWPF769402836
Please check the sample and let us know if you still facing the same issue? If not, please modify our sample based on your scenario and revert us back with the following details,
Issue reproducing video
It will be helpful for us to check on it and provide you with the solution at the earliest.
Regards,
SaiGanesh Sakthivel
Hello, now i find out that the issue is produced by following theme
"syncfusionskin:SfSkinManager.Theme="{syncfusionskin:SkinManagerExtension ThemeName=MaterialLight}"
with that line i get the exception postet above. If i use a other Theme example "FluentLight" the same issue.
But without theme it is working.
i cant reproduce the issue at your solution, because i have more views, and the issue is show if i swith the view as example from the schedule view to a contactsview with contacts and there the data is load async from a db.
i can sent you the hole solution if it helps.
now i think when i look at the stacktrace of the exception that there is a problem with the
System.Windows.DependencyObject.SetValueCommon() methode wich cant get the high
from Syncfusion.UI.Xaml.Controls.DataPager.NumericButton ?
and the theme "MaterialLight" has a issue wich let trhow the error
""NaN" ist not a valid value for property MaxHeight.greets.
Hi, now i think i have found my mistake ?
i should use to set the Theme:
SfSkinManager.SetTheme(this, new Theme() { ThemeName = "MaterialLight" });
not set with:
syncfusionskin:SfSkinManager.Theme="{syncfusionskin:SkinManagerExtension ThemeName=MaterialLight}"
at the mainView
Second different i see at your examples, you dispose the schedule view every time
and call SuppressFinalize(this);
Should we dispose all Syncfusion controls this style ?
Disposing Schedule Control:
protected override void Dispose(bool disposing)
{
if (this.Schedule != null)
{
this.Schedule.Dispose();
this.Schedule = null;
}
base.Dispose(disposing);
}
and the base class implements
IDisposable
:
public void Dispose()
{
// Dispose of unmanaged resources.
Dispose(true);
// Suppress finalization.
GC.SuppressFinalize(this);
}
Hi Johannes,
#Query1: Regarding theme change for SfScheduler
We are glad to know that you have found the solution from our end. You can also refer to our UG documentation to know more about changing Syncfusion controls themes,
UG: https://help.syncfusion.com/wpf/themes/skin-manager?cs-save-lang=1&cs-lang=csharp#set-theme
#Query2: Regarding Dispose calling for the SfScheduler
Calling the Dispose method for the custom control (like SfScheduler) in order to clear the local objects stored in the local.
GC.SuppressFinalize is called to request the CLR that the object is disposed and there is no need to call the finalizer for that object. We are following Microsoft guidelines to dispose objects and SuppressFinalize usage. Kindly refer to the Microsoft documentation for the same,
Implement a Dispose method
Regards,
SaiGanesh Sakthivel
thanks for your great help ;) we can close this issue.