I want to change the default value for Font Size in Windows Phone 8. that come from theme
I want to change the PhoneFontSizeExtraExtraLarge font size.
I tried
(Resources["PhoneFontSizeExtraExtraLarge"]) = 20;
but didn't work.
This can not be done directly.
We can create themes or styles that can be assign to buttons and textviews.
Example
<Style x:Key="Regular_24_BlackBrush" TargetType="TextBlock">
<Setter Property="FontFamily" Value="{StaticResource PhoneFontFamilyNormal}"/>
<Setter Property="FontSize" Value="24"/>
<Setter Property="Foreground" Value="{StaticResource BlackBrush}"/>
</Style>
Related
I have a user control with defined resources.
Here is some code for illustration.
<UserControl.Resources>
<SolidColorBrush x:Key="foregroundColor" Color="Red"/>
<Style x:Key="buttonFontIconStyle" TargetType="FontIcon">
<Setter Property="FontFamily" Value="Segoe MDL2 Assets"></Setter>
<Setter Property="Foreground" Value="{Binding ???}"></Setter>
</Style>
<Style x:Key="menuItemLabelStyle" TargetType="TextBlock">
<Setter Property="VerticalAlignment" Value="Center"></Setter>
<Setter Property="Foreground" Value="{Binding ???}"></Setter>
</Style>
</UserControl.Resources>
Now, I wish to use value defined in foreground color for buttonFontIconStyle, menuItemLabelStyle (and many others). Is it somehow possible to bind to value from resources in resources, or is there a way to specifiy color once (in xaml preferrably) and use it in multiple resources styles?
You can use the StaticResource :
<Style x:Key="buttonFontIconStyle" TargetType="FontIcon">
<Setter Property="FontFamily" Value="Segoe MDL2 Assets"></Setter>
<Setter Property="Foreground" Value="{StaticResource foregroundColor}"></Setter>
</Style>
<Style x:Key="menuItemLabelStyle" TargetType="TextBlock">
<Setter Property="VerticalAlignment" Value="Center"></Setter>
<Setter Property="Foreground" Value="{StaticResource foregroundColor}"></Setter>
</Style>
I have recently started a Xamarin Forms project specifically for the Universal Windows Platform. In attempt to add some global styles for the application, I have come across an element I don't know the uwp equivalent syntax for: Xamarin ContentView.
(ie. I know that Xamarin Label = UWPTextBlock, Xamarin HorizontalOptions = UWPHorizontalAlignment)
Xamarin:
<Style x:Key="errorContainer" TargetType="ContentView">
<Setter Property="BackgroundColor" Value="Red"/>
<Setter Property="HorizontalOptions" Value="Fill"/>
<Setter Property="Padding" Value="15"/>
</Style>
UWP:
<Style x:Key="errorContainer" TargetType="?????????">
<Setter Property="Background" Value="Red"/>
<Setter Property="HorizontalAlignment" Value="Stretch"/>
<Setter Property="Padding" Value="15"/>
</Style>
tldr; Xamarin ContentView = UWP ??????
Thanks for the help
ContentControl (and it's derived types like Border) should fit your need.
(Because it has a ContentTemplate Property, as Xamarin.Forms' ContentView derives from TemplatedView.)
I have a probleme with the ListViewItem, I define the style like this:
<ListView.ItemContainerStyle>
<Style TargetType="ListViewItem">
<Setter Property="Margin" Value="0" />
<Setter Property="Padding" Value="0" />
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
<Setter Property="Background" Value="Red"></Setter>
</Style>
</ListView.ItemContainerStyle>
And the result is:
How can I do to stretch ListViewItems ?
Thanks a lot
The problem is not the ItemContainerStyle but the control that I put into the ListView.
The border doest not fit ListViewItem, to solve the problem I set the width to 280 px (320 - 20 * 2, Snapped ViewState)
I working on a metro app and I am using listview
listview automatically puts some space on right side for scroll. In my code there is no need for scrolling
I tried to disable it ScrollViewer.VerticalScrollBarVisibility="Disabled" or scrollmode=false but the space allways appears
is there a way I could disappear it because listview highlights on over and click mode and it looks bad
Create a copy of the current ListView Style by selecting Edit Additional Templates -> Edit Generated Item Container -> Edit a Copy (see screenshot below).
In the template copy, modify the Margin (last line shown below)
<Style x:Key="ListViewItemStyle" TargetType="ListViewItem">
<Setter Property="FontFamily" Value="{StaticResource ContentControlThemeFontFamily}"/>
<Setter Property="FontSize" Value="{StaticResource ControlContentThemeFontSize}"/>
<Setter Property="Background" Value="Transparent"/>
<Setter Property="TabNavigation" Value="Local"/>
<Setter Property="IsHoldingEnabled" Value="True"/>
<Setter Property="Margin" Value="0,0,18,2"/>
to
<Setter Property="Margin" Value="0" />
You'll also need to set ScrollViewer.VerticalScrollBarVisibility="Hidden" on the ListView itself (like you tried before(, or you can get adventurous and modify the template for the ListView itself (Edit Template) and remove the ScrollViewer and set the ItemsPanelTemplate to just StackPanel from VirtualizingStackPanel.
I want to be able to change the background color of a button in XAML when it's disabled but I don't know what to override.
Anybody know what I need to do?
I'm create a Windows 8 store app using XAML and C# 4.5.
My current button style is as follows:
<Style x:Key="MySaveButtonStyle"
TargetType="ButtonBase">
<Setter Property="FontFamily"
Value="Segoe UI Symbol" />
<Setter Property="FontSize"
Value="36" />
<Setter Property="Content"
Value="" />
<Setter Property="Height"
Value="70" />
<Setter Property="Width"
Value="80" />
<Setter Property="BorderBrush"
Value="White" />
<Setter Property="Foreground"
Value="{StaticResource ButtonForegroudBrush}" />
<Setter Property="BorderThickness"
Value="1" />
<Setter Property="Background"
Value="White" />
</Style>
Thanks is advance.
You have to override the Default ControlTemplate of the Button.
To do this: Right Click the button in Designer View - Edit Template - Edit a Copy
then Visual Studio creates the default Template for you.
In the Template Code there is a VisualStateManager Section with groups and states.
And one of them is
<VisualState x:Name="Disabled">
//Change to your demands
</VisualState>
Here you can change it to anything what you want to do when a control is Disabled.