I want to change the DatePicker Style of UWP - datepicker

I want to change the DatePicker Style of UWP as shown below.
I want year to come first and month to come second.
I modified the style but it does not work.
What should I do?
Thank you for your reply.

According to this article:
There are many different ways to properly display dates and times. Different regions and cultures use different conventions for the order of day and month in the date, for the separation of hours and minutes in the time, and even for what punctuation is used as a separator.
If you use date and time picker controls, these will automatically use the date and time formats for the user's preferred language and region. So the order is defined by the user's preferred language and region that you should not be able to change them by the style of DatePicker.
The first image you showed above seems like preferred language is en-US and home region is US. For scenarios where you provide different functionality based on the user's language, region, or cultural preferences, Windows gives you a way to access those preferences, through Windows.System.UserProfile.GlobalizationPreferences. And the second image seems like preferred language is Chinese. The preferred language can be override by property PrimaryLanguageOverride. Pay attention that the PrimaryLanguageOverride property should only be set to languages that are available for the user.
So if you change the prefer language to Chinese the DataPicker may be shown in order year-mouth-day. Also formats need be changed as the second image show. Code as follows:
<DatePicker BorderThickness="0" FontFamily="Arial Black" FontSize="15" FontWeight="Bold" MinWidth="190" DayFormat="{}{day.integer(2)}" MonthFormat="month.numeric" YearFormat="{}{year.full(4)}" />
Code behind
ApplicationLanguages.PrimaryLanguageOverride = "zh-Hans-CN";
And the result
To respect the user's Language and Cultural Preferences, this may not be recommended to change.

Related

Custom localisation in Flutter

There are options to select an language from the list of Language in my application i.e. English, Gujarati, Hindi.
After the selection, all the texts inside app should change and display according to language selection.
Note that This is not normal localisation (means selecting language from settings and then it reflects in app)
The question is How can I change the text content according to selected value of Language?
Thanks.
You can use this article: https://medium.com/#podcoder/flutter-localization-a39402757a42 (https://github.com/podcoder/flutter_localization)
This is an easy way to localize an application without using the system language.
Hope this helps.
I am currently using this method and it works very well.

SwiftUI Widget DateStyle Custom Format

Just wondering if there is a way to apply a custom format for the DateStyle comp within SwiftUI's Text UI. For Example just the minutes or seconds like you would when using a DateFormatter. I want to display the dynamic dates for a Widget but it only offers a limited number of options. Why is this and has anyone found a way around this?
Apple talk more about Displaying Dynamic Dates here: https://developer.apple.com/documentation/widgetkit/keeping-a-widget-up-to-date
You won't like this answer, but as of iOS 14, the answer is there's no way to customize the relative style for Text. The relative style is new in iOS 14, and as always, Apple provide the bare minimum feature.
For now, you have only these choices:
Use other Text.DateStyle, if they work for you
Fallback to DateFormatter (and other formatters) with the tradeoff that widget can only refresh couple of times in a day
Hopefully this won't be the answer with iOS 15 or later.

need consulting for a gui with 5 settings to be chosen by the user

I would like to let the user set 5 different settings. Each setting has a finite amount of values to choose (in my case : smaller, small, normal, large, very large)
I tried to use the UIPickerviews for this, but it needs a lot of space and I would like to have all on one page. I realized, that apple doesn't support simple dropdowns in IOS!?!?
following sample just shows only one setting and it fills up 1/3 of the screen.
In Android I managed to do this with simple dropdowns.
Any hints on how I could do this, without programming my own dropdown box ?
iOS does not have dropdowns as you say. I have created a custom control for my company that implements a dropdown. Some of my fellow iOS developers have yelled at me and said the dropdowns don't follow Apple's HIG. (You can take a look at our free app FaceDancer to see our dropdown control if you're interested.)
Apple uses picker views instead. What you can do is to have some sort of clickable element for each item (buttons for each one, e.g. "pick size", or make each field itself clickable) that displays a picker on top of the screen to let the user pick that value.
Note that there are large numbers of (both free and paid) third party frameworks offering all kinds of additional controls. I bet somebody has implemented a drop-in dropdown menu for iOS. Take a look at CocoaControls and search the iOS section for "dropdown". You can also look on Github and SourceForge.net.
I solved my problem by using a UISegmentedControl.
In my case with only 5 values, for me its the best choise. But for more then 10 values we have to use obviously external controls as Duncan mentoined.
var arraySizes5 = [sverysmall, ssmall, snormal, slarge, sverylarge];
var segmentcontrol_TextSizeTextViewer = UISegmentedControl();
segmentcontrol_TextSizeTextViewer = UISegmentedControl(items: arraySizes5);
self.view.addSubview(segmentcontrol_TextSizeTextViewer);

Calendar switching in Matlab GUI (DateChooserPanel)

I have a question about Matlab GUI's. I'm gonna try and explain as best as I can what exactly I need help for.
I am using GUIDE for building GUI, and have a listbox with ~10 names in it. When I click on each of the names (individuals) a calendar will appear where I can select multiple dates on.
Each person has it's own calendar which appears when you click on their name for the first time. Every calendar is created in the same place(coordinates) on GUI. Calendars become visible (are created) after the listbox selection, at first only listbox is visible on the GUI.
The thing I want to do is to be able to switch between each of these calendars depending on what person's name I click on the listbox. For example, click on 'martin' shows his calendar, click on 'joe' brings his calendar up front etc. So basically, I have ~10 calendars I want to switch between (while the selected dates don't reset with each switch).
I am using Jide's DateChooserPanel which is implemented in Matlab, as it is really easy to use and is just perfect for my needs.
The following code generates a calendar and sets an ability to select multiple dates and works perfect:
com.mathworks.mwswing.MJUtilities.initJIDE;
jPanel = com.jidesoft.combobox.DateChooserPanel;
[hPanel,hContainer] = javacomponent(jPanel,[219,66,200,200],gcf);
jModel = hPanel.getSelectionModel;
jModel.setSelectionMode(jModel.MULTIPLE_INTERVAL_SELECTION);
And I can get the chosen dates with this line:
hPanel.getSelectionModel.getSelectedDates
And now I'm stuck because I don't know how to switch between those calendars. I was trying to get their handles and somehow get that person's calendar in front of the others, but I couldn't find a way.
Any advice/help is appreciated!

Remove the "Today" entry from UIDatePicker

When using a UIDatePicker in iOS SDK, there is always an entry "Today" at the current date.
That's useful in most cases, but where I need it, it's rather confusing.
Is there a way to:
a) disable the "today"-entry (use regular date instead), and have all entries look the same
or even better
b) disable the "today"-entry (use regular date instead), and color the next day in blue
Further more, the application is for private use only, it's not going to get distributed on the AppStore, which means I could use private APIs (I still would rather avoid them) and I don't need it to be backwards compatible. iOS 4 is fine.
I had a similar problem with the UIDatePicker not matching my requirements exactly (in my case I needed a datepicker without a year wheel). Having a look at the UIDatePicker reference, it doesn't look like you can disable the today entry, so you might be forced to do what I did.
I used a UIPickerView and re-implemented the date selection functionality I needed with that. There are a few things you will need to do to implement your custom date picker:
Implement a UIPickerViewDataSource to set up row titles, dimensions and row counts.
Implement a UIPickerViewDelegate to handle events from your custom picker.
Make sure you update your day wheel when the month wheel changes so you get appropriate days for each month. UIDatePicker does this pretty seamlessly. With limited time, I just reload the picker when the month changes so the day counts match up.