We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The value of SelectedDateTime of the TimePicker control is double somehow and exception falls when binding with a converter.
SelectedDateTime
TimePicker
double
I save my datetime as long number yyyyMMddHHmm and convert it for display.
yyyyMMddHHmm
here is my details:
version installed:
<package id="MahApps.Metro" version="2.4.10" targetFramework="net472" />
window xmlns:
xmlns:mah="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
window coverter definition:
<mah:MetroWindow.Resources> <local:TimeConverter x:Key="TMCNV" /> <local:DateTimeConverter x:Key="DTCNV" /> <local:StatConverter x:Key="STCNV" /> </mah:MetroWindow.Resources>
control at XAML:
<mah:TimePicker x:Name="timePopup" Grid.Row="3" Grid.Column="1" Margin="3" HorizontalAlignment="Left" Width="150" Culture="he-IL" SelectedTimeFormat="Short" SelectedDateTimeChanged="timePopup_SelectedDateTimeChanged" SelectedDateTime="{Binding PHdr.TimePopup,Mode=TwoWay,Converter={StaticResource TMCNV}}" />
converter class code
internal class TimeConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { if ((long)value == 0) return new DateTime(1973, 02, 07, 0, 0, 0); long d1 = long.Parse(DateTime.Today.ToString("yyyyMMddHHmm")); d1 = d1 + (long)value; DateTime d2 = DateTime.Today; try { d2= DateTime.ParseExact(d1.ToString(), "yyyyMMddHHmm", CultureInfo.InvariantCulture); } catch { } return d2; } public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { if (value == null) return (long)0; return long.Parse(((DateTime)value).ToString("yyyyMMddHHmm")); } } }
to trigger the bug use the code and try to change the Time then it will appear
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Describe the bug
The value of
SelectedDateTime
of theTimePicker
control isdouble
somehow and exception falls when binding with a converter.I save my datetime as long number
yyyyMMddHHmm
and convert it for display.here is my details:
version installed:
window xmlns:
window coverter definition:
control at XAML:
converter class code
to trigger the bug use the code and try to change the Time then it will appear
The text was updated successfully, but these errors were encountered: