Hi I want to change the fontfamily and fontsize of CalendarDatePicker popup, the control has both property but it will only apply for the display text after date is selected not on the popup that opens when you want to select date.
You need to change the CalendarViewStyle of your CalendarDatePicker. To change the FontFamily and FontSize you need to update the DayItemFontFamily and DayItemFontSize properties like following:
<CalendarDatePicker>
<CalendarDatePicker.CalendarViewStyle>
<Style TargetType="CalendarView">
<Setter Property="DayItemFontFamily" Value="Comic Sans MS" />
<Setter Property="DayItemFontSize" Value="8" />
</Style>
</CalendarDatePicker.CalendarViewStyle>
</CalendarDatePicker>
Also you can change a bunch of other useful properties like the SelectedBorderBrush, TodayForeground, CalendarItemBackground, MonthYearItemFontFamily and more.
The default style of the CalendarView can be found here and more info about the CalendarView class can be found here. I would suggest you read through the Remarks section, especially Customizing the CalendarView's appearance, where all properties are listed which change the appearance of the calendar.
I have used the font Comic Sans MS but for a full list of available fonts check here.
Related
I have a Style with target type Grid. I want all Entry child elements within a grid of this style to automatically acquire a particular style.
I've had a look at these:
Styling nested elements in WPF
Apply Style to all child-elements of specific type
The only solution appears to be setting Resources within the parent Style, so this is what I've done:
<Style x:Key="BuggyGrid" TargetType="Grid">
<!-- bunch of property setters -->
<Style.Resources>
<Style TargetType="Entry">
<Setter Property="FontFamily" Value="Arial" />
</Style>
</Style.Resources>
</Style>
However, I get a build error:
"No property, bindable property, or event found for 'Resources'".
Why do I get this error?
I'm using Xamarin.Forms 2.3.2.
The links you have referenced are specific to WPF XAML and do not apply to Xamarin.Forms XAML.
I'm not sure how you would achieve nested styles in Xamarin.Forms.
The only possibility is XamlCSS which I haven't personally used.
https://www.nuget.org/packages/XamlCSS.xamarinforms/2.0.0-pre1
The official Microsoft article states:
Modify the default system styles
You should use the styles that come from the Windows Runtime default XAML resources when you can. When you have to define your own styles, try to base your styles on the default ones when possible (using based-on styles as explained earlier, or start by editing a copy of the original default style).
I understand that you can copy and paste the default style from MSDN in order to "start by editing a copy of the original". However, that strikes me as very ugly and inelegant, as I'm pasting in almost a 100 lines even if I just want to add one thing.
I like the idea of "using based-on styles" to include all of the default style by reference, but from what I can tell the original default styles supplied by Microsoft are implicit. Given that they have no key to reference them by, how can BasedOn be used?
You are right about that BasedOn won't work with default styles as they are implicit.
However, you don't have to include the full style code if you simply want to edit some properties.
For example, the Button below will inherit everything from the default style except the Background color being changed to Red.
<Page.Resources>
<Style x:Key="RedButtonStyle"
TargetType="Button">
<Setter Property="Background"
Value="Red" />
</Style>
</Page.Resources>
<Grid>
<Button Content="Red" Style="{StaticResource RedButtonStyle}" />
</Grid>
I need to show ContentDialog that is not attached to any page.
Currently I construct it dynamically in the code.
How can I define it in XAML?
By adding a UserControl item to your project and changing its base type to ContentDialog with the following Body:
<ContentDialog .../>
-or-
<ContentDialog>
singleObject
</ContentDialog>
-or-
<ContentDialog>stringContent</ContentDialog>
See MSDN link
Pretty much title. catel:TabControl's background remains white whatever MahApps' theme is.
I can't tell if it's the only Catel control behaving this way, since I didn't test every and each one of them.
But there it is, it's not getting affected by MahApps' selected theme (BaseDark or BaseLight). It wasn't obvious since I started with the light one, so the TabControl was white as expected, but once I switch to the dark theme, it remains white.
This problem is already solved in Orchestra (https://github.com/WildGums/Orchestra).
I think you should override the Catel's tab control style like following:
<windows:MetroDataWindow.Resources>
<ResourceDictionary>
<Style TargetType="catel:TabControl" BasedOn="{StaticResource {x:Type TabControl}}" />
</ResourceDictionary>
</windows:MetroDataWindow.Resources>
You can check the example in the Orchestra.Shell.MahApps project in Orchestra:
Points of interest:
Orchestra.Examples.MahApps/Orchestra.Examples.MahApps.Shared/Views/MainView.xaml
Orchestra.Shell/Orchestra.Shell.MahApps/Orchestra.Shell.MahApps.Shared/Views/ShellWindow.xaml
To enable dark MahApps theme in Orchestra you should add the following code to Orchestra.Shell/Orchestra.Shell.MahApps/Orchestra.Shell.MahApps.Shared/Themes/Generic.xaml
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseDark.xaml" />
Please let me know if this helps.
I'm trying to override the padding property of a ListViewItemPresenter in Windows Store apps.
Everything works when I copy the complete generic ListView style, change the padding and apply that style as ItemContainerStyle to my ListView.
Now I need to do this for another ListView. How can I override just one property of the ListViewItemPresenter ControlTemplate without copying the complete style all over again?
The best solution I have found came from the link below. I copy-pasted the answer below.
The idea is to copy the full Windows 10 style into your dictionary and give it a key. You don't need to modify the style and you only have to copy it once. (Though once more than ideally you should have to.) Since it now has a key, you can create another style "BasedOn" that key and modify it.
[https://social.msdn.microsoft.com/Forums/en-US/d3c1f120-b11f-4d14-b45c-7bdf3e9233be/inheriting-a-default-application-style-xaml?forum=winappswithcsharp][1]
First, create the default style for the control in your App.xaml-level resource dictionary, but give it an x:Key
<Style x:Key="ButtonDefaultStyle" TargetType="Button">
...
</Style>
Then, create another style that inherits from this style.
<Style x:Key="MyButtonStyle" TargetType="Button" BasedOn="{StaticResource ButtonDefaultStyle}" />
</Style>
Default styles can be found here
[https://msdn.microsoft.com/en-us/library/windows/apps/mt299122.aspx]
or on your computer at a location like
C:\Program Files (x86)\Windows Kits\10\DesignTime\CommonConfiguration\Neutral\UAP\10.0.10586.0\Generic\generic.xaml