Status Bar - Accent as Background Color - windows-10-universal

How to make that system accent color is background color of status bar in Windows 10 mobile app? I cannot figure out how to convert theme resource to background color in c#... Thank you!

You can get it with Application.Current.Resources
Example
XAML
<Button x:Name="myButton" >AAA</Button>
C#
myButton.Background = (SolidColorBrush) Application.Current.Resources["SystemControlBackgroundAccentBrush"];
Result
I hope that can help you

There is no need to set it in code behind. Just use pure xaml:
<Button Background="{StaticResource SystemControlBackgroundAccentBrush}"/>

Related

Find MahApps Metro title bar color

I am using MahApps Metro and i'm trying to get to TitleBar color to use it with other controllers:
In App.xaml file all i can see is:
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseLight.xaml" />
Which is the theme name, i can change BaseLight to Red for exapmle and my TitleBar become Red but i really like this color.
Any suggestions how to find this color ?
It should be
AccentColorBrush
You can access it like this:
<TextBox Background="{DynamicResource AccentColorBrush}" />

Style in HeaderColumn in Datagrid

Please see this following image of my datagird.
Now want a border in headerColumn. I have tried columnheader style but it did not work for me.
I want following style of header of datagrid.Please see the following image.
How can i achieve this style in datagird.
Thanks
You have to change the DataGrid template, not columnheader. In the default DataGrid template there is:
<sdk:DataGridColumnHeadersPresenter x:Name="ColumnHeadersPresenter" Grid.Column="1"/>
I think you have to edit over there.

Any way in WPF to add a top margin SpellCheck squiggle in textBox?

Hi I have enabled spellcheck in my WPF TextBox like so:
<TextBox SpellCheck.IsEnabled="True" Width="200" />
I would like to add a small top margin to the squiggle decoration.
Is this possible?
(btw. is this possible for any textdecoration in wpf like say underline in a textblock?)
Thanks, any help appreciated.

WP7 -- Context Menu Forces Black Background for Listbox

This is probably an easy one... I have a Listbox with a ContextMenu embedded in it, and every time the ContextMenu appears, the Listbox changes its background to opaque black. How do I prevent this from happening?
Here is some sample XAML:
<ListBox x:Name="FolderItems" ItemTemplate="{StaticResource ItemTemplate}" ItemContainerStyle="{StaticResource ItemListBox}" SelectedItem="{Binding SelectedItem, Mode=TwoWay}" ItemsSource="{Binding FolderItems}">
<toolkit:ContextMenuService.ContextMenu>
<toolkit:ContextMenu
x:Name="FolderContextMenu"
Margin="20"
Background="WhiteSmoke"
BorderBrush="Black"
BorderThickness="1.0"
Closed="ContextMenu_Closed">
<toolkit:MenuItem Loaded="ContextMenuItem_Loaded"
Opacity="0.0" Margin="5" Background="Transparent"
Click="ContextMenuItem_Click" Name="ContextMenuDelete">
<toolkit:MenuItem.Header>
<TextBlock Text="delete" FontFamily="Segoe WP Bold"/>
</toolkit:MenuItem.Header>
</toolkit:MenuItem>
</toolkit:ContextMenu>
</toolkit:ContextMenuService.ContextMenu>
</ListBox>
Thanks
Update
I still haven't figured out why the entire listbox goes black when the context menu appears. I've set everything I can think of to a transparent brush.
I fixed this for my situation by opening up the toolkit (downloading the source: Silverlight Toolkit), and editing the color values myself in ContextMenu.cs . Then, I rebuilt and targeted the dll that I created rather than the one from the installer.
The only issue is that I will now need to do this application specific, but at least I can have a resolution. I believe also that if you set IsZoomEnabled=false, it won't have this behavior in the first place, but it's a different experience.
Here's my edited version: Pastebin
Check out the lines like this, they're the ones you'll need to change:
// Create a layer for the element's background
UIElement elementBackground = new Rectangle
{
Width = ownerElement.ActualWidth,
Height = ownerElement.ActualHeight,
Fill = new SolidColorBrush(Colors.White),
};
Good luck!
There's a simple way to do this. For some reason MS Access complements the colors when using a list box. If you set the foreground to red, it will show green, etc.
So, set the background color to black (0) and the foreground color to white (16777215). Counter-intuitive but it works is MS Access 2002.
Without seeing the template you're using I can't say for sure but you've probably hardcoded a background value but not considered the different states of the list items and the default state colour/value is being displayed

Silverlight button style

I am trying out new styles with silverlight, and I created a new button skin with blend that consists of a border and a textblock. Wondered if there is a way to change the the text of the textblock when the the button's content(text) property is changed.
The binding would look like this:
<TextBlock Text="{TemplateBinding Content}"/>
The problem is when I try to set the content to something other than text:
<Button>
<Button.Content>
<Rectangle Fill="#FFB51111"/>
</Button.Content>
</Button>
In this case using the ContentPresenter would work better. It uses the same binding expression, but can display more than text. But all that is really up to you.
I don't really get what your trying to do. Normally, you include a TextBlock like that as a part of the button content.
Use a ContentPresenter rather than a TextBlock in your Template.

Resources