本地化默认的 Windows Phone 日期选择器

发布于 2025-01-05 16:24:45 字数 348 浏览 1 评论 0原文

我已经本地化了整个应用程序,但无法本地化日期选择器。在论坛中的一些搜索给了我一些答案 喜欢这个

,但我找不到带有不同语言工具包的 resx 的属性文件夹!我刚刚在解决方案资源管理器中的参考下添加了工具包参考,这样我就可以访问日期选择器。我创建了一个名为 toolkit.content 的文件夹来放置“确定”和“取消”图像。

那么我如何为工具包日期选择器添加 resx :(

I have localised the whole app but not able to localise the date picker. A bit of searchin in the forum gave me few answers like this one

but i cant find a properties folder with the resx for different lang for toolkit! I have jus added the toolkit reference in the solution explorer under reference and thats im able to access date picker. I have made a folder called toolkit.content to put the ok and cancel images.

so how do i add the resx for the toolkit date picker :(

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

<逆流佳人身旁 2025-01-12 16:24:45

您还可以创建一个继承自原始 DatePicker 的自定义控件。

 public class MyDatePicker : Microsoft.Phone.Controls.DatePicker
{
    public string PickerPageHeader
    {
        get { return (string)GetValue(PickerPageHeaderProperty); }
        set { SetValue(PickerPageHeaderProperty, value); }
    }

    // Using a DependencyProperty as the backing store for PickerPageHeader.  This enables animation, styling, binding, etc...
    public static readonly DependencyProperty PickerPageHeaderProperty =
        DependencyProperty.Register("PickerPageHeader", typeof(string), typeof(MyDatePicker)
        , new PropertyMetadata("Choose date text in your language"));

    public MyDatePicker()
    {
        base.PickerPageUri = new Uri("/Sample;component/CustomControls/MyDatePickerPage.xaml?Header=" + PickerPageHeader, UriKind.Relative);
       //Don't forget to change the project name and xaml location
    }
}

并在 CustomControls 文件夹中创建选择器页面 xaml 文件:

<toolkit:DatePickerPage
x:Class="Sample.MyDatePickerPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
/>

代码隐藏:

public partial class MyDatePickerPage : Microsoft.Phone.Controls.DatePickerPage
{
    public MyDatePickerPage ()
    {
        InitializeComponent();

        foreach (var item in base.ApplicationBar.Buttons)
        {
            IApplicationBarIconButton button = item as IApplicationBarIconButton;
            if (null != button)
            {
                if ("DONE" == button.Text.ToUpper())
                {
                    button.Text = "done in your language";
                }
                else if ("CANCEL" == button.Text.ToUpper())
                {
                    button.Text = "cancel in your language";
                }
            }
        }
    }

    protected override void OnNavigatedTo(NavigationEventArgs e)
    {
        (base.FindName("HeaderTitle") as TextBlock).Text = e.Uri.OriginalString.Substring(e.Uri.OriginalString.IndexOf("Header=") + 7);
        base.OnNavigatedTo(e);
    }
}

You can also create a custom control which inherits from the original DatePicker.

 public class MyDatePicker : Microsoft.Phone.Controls.DatePicker
{
    public string PickerPageHeader
    {
        get { return (string)GetValue(PickerPageHeaderProperty); }
        set { SetValue(PickerPageHeaderProperty, value); }
    }

    // Using a DependencyProperty as the backing store for PickerPageHeader.  This enables animation, styling, binding, etc...
    public static readonly DependencyProperty PickerPageHeaderProperty =
        DependencyProperty.Register("PickerPageHeader", typeof(string), typeof(MyDatePicker)
        , new PropertyMetadata("Choose date text in your language"));

    public MyDatePicker()
    {
        base.PickerPageUri = new Uri("/Sample;component/CustomControls/MyDatePickerPage.xaml?Header=" + PickerPageHeader, UriKind.Relative);
       //Don't forget to change the project name and xaml location
    }
}

And create picker page xaml file in a CustomControls folder:

<toolkit:DatePickerPage
x:Class="Sample.MyDatePickerPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
/>

Code behind:

public partial class MyDatePickerPage : Microsoft.Phone.Controls.DatePickerPage
{
    public MyDatePickerPage ()
    {
        InitializeComponent();

        foreach (var item in base.ApplicationBar.Buttons)
        {
            IApplicationBarIconButton button = item as IApplicationBarIconButton;
            if (null != button)
            {
                if ("DONE" == button.Text.ToUpper())
                {
                    button.Text = "done in your language";
                }
                else if ("CANCEL" == button.Text.ToUpper())
                {
                    button.Text = "cancel in your language";
                }
            }
        }
    }

    protected override void OnNavigatedTo(NavigationEventArgs e)
    {
        (base.FindName("HeaderTitle") as TextBlock).Text = e.Uri.OriginalString.Substring(e.Uri.OriginalString.IndexOf("Header=") + 7);
        base.OnNavigatedTo(e);
    }
}
走走停停 2025-01-12 16:24:45

您必须获取 ToolKit 的源代码并使用本地化内容重建它

WP7 ToolKit 源< /a>

You have to get the source for the ToolKit and rebuild it with your localization

WP7 ToolKit Source

余生一个溪 2025-01-12 16:24:45

非常简单:参数-语言。
XAML代码:

<toolkit:DatePicker Language="ru-RU" Margin="-12, 0" Value="{Binding BirthDate, Mode=TwoWay}" />

It's very simple: Parameter - Language.
Xaml code:

<toolkit:DatePicker Language="ru-RU" Margin="-12, 0" Value="{Binding BirthDate, Mode=TwoWay}" />
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文