windows phone display hijri date picker - calendar

Can you please let me know how can I modify the silverlight toolkit date picker (toolkit:DatePicker) to work with hijri calendar
Regards.

Here we go the answer to your question which is tested on windows mobile 8
CultureInfo sa = new CultureInfo("ar-SA");
sa.DateTimeFormat.Calendar = new System.Globalization.HijriCalendar();
Thread.CurrentThread.CurrentCulture = sa;
// Sets the UI culture to Arabic (Saudi Arabia)
Thread.CurrentThread.CurrentUICulture = sa;

Related

change culture using wpflocalizeextension

maybe it's very simple, but how to change the culture in code behind to allow the wpflocalizeextension to show the desired resource?
I tried to change the application culture, but it did nothing!!
In order to change the current culture at runtime you use the following two statements. With SetCurrentThreadCulture, also the culture of the current thread is updated.
WPFLocalizeExtension.Engine.LocalizeDictionary.Instance.SetCurrentThreadCulture = true;
WPFLocalizeExtension.Engine.LocalizeDictionary.Instance.Culture = new CultureInfo("en");
To get a list of available CultureInfo objects, you can use
WPFLocalizeExtension.Engine.LocalizeDictionary.Instance.MergedAvailableCultures
Try something like this?
CultureInfo.DefaultThreadCurrentCulture = new CultureInfo("en-US");
CultureInfo.DefaultThreadCurrentUICulture = new CultureInfo("en-US");

silverlight application wide date

Is there a way to define a application wide format for the dates in Silvelight. So far I've tried to add this code in App_Startup:
CultureInfo culture = (CultureInfo)CultureInfo.CurrentCulture.Clone();
culture.DateTimeFormat.ShortDatePattern = "dd-MM-yyyy";
culture.DateTimeFormat.FullDateTimePattern = "dd-MM-yyyy";
culture.DateTimeFormat.ShortTimePattern = "dd-MM-yyyy";
Thread.CurrentThread.CurrentCulture = culture;
Thread.CurrentThread.CurrentUICulture = culture;
But all my date binding don't take this into consideration.
Regards,
Create a string resource in your App.xaml
<System.String x:Key="MyDateFormat">dd-MM-yyyy</System.String>
And use it as a static resource in your bindings' string format
<TextBlock Text={Binding MyDateProperty, StringFormat={StaticResource MyDateFormat}} />
I haven't tested this, but that would be my first try.
Try accepted answer from here - DateTime Not showing with currentculture format in Datagrid,ListView.
This works for WPF, you can try it for Silverlight to make it respect your culture.
There is a partial solution for this here: http://timheuer.com/blog/archive/2010/08/11/stringformat-and-currentculture-in-silverlight.aspx
This may not work at the application level though - you may need to apply the solution to various other classes e.g. your child windows.

ReportViewer databinding (WPF)

I have a rdlc file and I try to show it using report viewer control in WPF. My DataSource is called 'OfficeDataSet' and DataSet used in report is called 'Address'. I try to initialize report viewer (I put it in WindowsFormsHost) like this:
private void PrepareReport()
{
reportDataSource = new ReportDataSource();
officeDataSet = new OfficeDataSet();
adapter = new AddressTableAdapter();
adapter.Fill(officeDataSet.Address);
reportDataSource.Name = "OfficeDataSet_Address";
reportDataSource.Value = officeDataSet.Address;
viewerInstance.LocalReport.DataSources.Add(reportDataSource);
viewerInstance.LocalReport.ReportEmbeddedResource = "WpfApplication1.Reports.TestReport.rdlc";
viewerInstance.Location = new System.Drawing.Point(0, 0);
viewerInstance.RefreshReport();
}
but I got the message "A data source instance has not been supplied for the data source 'Address'".
Anybody know what can be wrong with this code? (I'm totally new in WPF and Reporting Services).
If i remember well, the datasource into the report file should have the same name (or maybe value) as the reportDataSource. So in your report file the datasource should be called "OfficeDataSet_Address".

Setting thread culture to default

In silverlight application I have MyTexts.resx (for english) and MyTexts.ja-JP.resx (for japanese) resource files. Before loading a page I can set current culture to japanese as following:
Thread.CurrentThread.CurrentCulture = new CultureInfo("ja-JP");
Thread.CurrentThread.CurrentUICulture = new CultureInfo("ja-JP");
But sometimes I need to reset culture to default. How can I do that? The following wouldn't work:
Thread.CurrentThread.CurrentCulture = new CultureInfo("default");
OR
Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
I myself seem to find an answer:
Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
Thread.CurrentThread.CurrentUICulture = CultureInfo.InvariantCulture;

How can I disable future dates in the Silverlight DatePicker control

I need to be able to disable the selection of future dates within the Silverlight DatePicker control - any ideas ?
http://msdn.microsoft.com/en-us/library/system.windows.controls.datepicker.displaydateend(VS.95).aspx
DatePicker.DisplayDateEnd = DateTime.Now;
?
Use the MaxDate to Blackout the future dates
System.DateTime DatesDisplayEnd = today.Add(duration);
System.DateTime MaxDate = DateTime.MaxValue;
stkDatePicker.BlackoutDates.Add(new CalendarDateRange(DatesDisplayEnd, MaxDate));

Resources