我无法在telerik datepicker中更改日期格式。 我正在尝试以下程序。 我从This link
找到了以下代码 public class TelerikDateFormatWorkaround
{
public CultureInfo CultureWithSwissFormat
{
//Hack to get around the fact that there is no custom date format in the Telerik DatePicker
//http://www.telerik.com/community/forums/wpf/datepicker/changing-dateformat.aspx
get
{
var tempCultureInfo = (CultureInfo) CultureInfo.CurrentCulture.Clone();
tempCultureInfo.DateTimeFormat.ShortDatePattern = "dd.MM.yyyy";
return tempCultureInfo;
}
}
}
<Window.Resources>
<Style TargetType="telerik:RadDatePicker">
<Setter Property="Culture" Value="{Binding Source={StaticResource TelerikDateFormatWorkaround}, Path=CultureWithSwissFormat}"/>
</Style>
</Window.Resources>
但错误是The TelerikDateFormatWorkaround was not found.
你能帮助我吗?
答案 0 :(得分:2)
您应该在xaml中创建TelerikDateFormatWorkaround
的实例:
<Window.Resources>
<local:TelerikDateFormatWorkaround x:Key="TelerikDateFormatWorkaround" />
<Style TargetType="telerik:RadDatePicker">
<Setter Property="Culture" Value="{Binding Source={StaticResource TelerikDateFormatWorkaround}, Path=CultureWithSwissFormat}"/>
</Style>
</Window.Resources>
local
是您定义TelerikDateFormatWorkaround
class:
xmlns:local="clr-namespace:TelerikWorkaround"