1

我无法更改 Telerik DatePicker 中的日期格式。我正在尝试以下程序。我在这里找到了以下代码

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.

你能帮助我吗?

4

1 回答 1

2

TelerikDateFormatWorkaround您应该在 xaml 中创建实例:

<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类的名称空间:

xmlns:local="clr-namespace:TelerikWorkaround"
于 2013-10-20T18:28:22.003 回答