WP7 Trouble customizing DatePicker control - c#

I'm using the DatePicker control from the WP7 SL toolkit. It navigates to DatePickerPage.xaml, which has the scrollers for date picking. I want to keep all the functionality, but change the colors. I'm messing around with DatePickerPage.xaml and updating colors to fit my needs.
I've been able to update the text colors on the scrollers and header, but I can't figure out how to update the background color on the selected item in each or the square outline while the scroller is active. Based on tests I have done with changing the background color of the DatePickerPage.xaml, it appears that the selected item and square outlines are an opaque version of the background color. Unfortunately, this wont work for me, since I want the background to the be white and the outlines aren't visible. Is there a way to explicitly set those colors?

If you get the control into Blend and right click on it and select Edit Tempate --> Edit a Copy, you'll get the template for the control so that you can edit it.
What you'll be looking for is the resources keys that are used for the background, foreground, etc. You can replace them with your own resources, or hardcode them, or the best option is to override the resource.
Additional Advice
Be careful though, don't forget that a user can have either a dark or light background to the phone, so unless your app is taking control of the background color of the whole page, you need to consider what might happen when picking colors

Related

How to set "keyboard tab borders" not to cover the rest of the UI?

I'm working on a UWP app and I'm having some trouble with the visual states of some UI controls, specifically with buttons and toggle buttons.
Basically, I'd like the borders that become visible when you press the TAB key (to navigate using the keyboard) to have the same ZIndex of the rest of the control, ie. if part of the control is covered, they should be covered too in the same way. But, it looks like these borders are always displayed on top of the UI, no matter what. Here's a screen:
You can see the border going over the rest of the UI, while the rest of that toggle button is correctly covered. The same happens for buttons as well (not only toggle buttons), see here:
I've looked at the template for these controls, but I couldn't find anything related to these specific borders, nor to anything like an explicit Canvas.ZIndex setting or something like that.
I guess this behavior is on purpose, but is there a way to change this and make those borders behave like the rest of the UI?
Thanks!
EDIT: here you can see how a reveal highlight effect is correctly covered by the shadow and the other UI elements on the right, but the TAB border ignores that and is displayed on top of them.
I have noticed similar behavior was previously present in the Start menu as well (although it wasn't with focus border, but with the reveal effect clearly "continuing" into the cut-off portion of the button.
One workaround that comes to mind is to observe the state of the SplitView and when it is closed to actually change the width of the buttons (for example via a StateTrigger). This way the button's area will no longer be "hidden" and the focus border will work properly, as the buttons will end where they should.

Set text color for DatePicker in disabled state?

I am using a lot of DatePickers in my C#/WPF application. The people who will be using this app. usually are old and have problems with seeing/reading.
I need to change the pale color of the text to something darker so anyone can read the text in the DatePicker.
How and where can I do that?
I am using Visual Studio 2010 and I see only 4 color properties in Brushes section: Background, BorderBrush, Foreground and OpacityMask.
Or I should be doing this with code, set the Brush with code?
The Foreground property sets the text of the DatePicker in an enabled state. When the DatePicker is disabled, the control template adds a semi-transparent overlay to the control.
You can find the default template here. The overlay is defined in the PART_DisabledVisual Grid. To fix your issue, you can copy the entire ControlTemplate in your code and modify the two Rectangles with Fill="#A5FFFFFF" to Fill="Transparent".

How do I remove the back color or a tab control?

I already tried putting a back color for each of the tab pages - but the extra space for the buttons of the tab control still takes the default color.
You could make the window smaller overall, to be the width of the list of tabs. Although I'm not sure if you can sacrifice the space.
Other than that, I'm not sure if you can with the default Windows Controls. Try looking into something like Infragistics, which adds on to the default windows controls with their own.

How to get image control color using C# or Coded UI?

I have one green checkmark (an image control). I have to verify that the checkmark is green. I am not able to get the color. Can you help me?
Coded UI is about checking the functionality of an application. It is not so good at checking the aesthetics (ie colour, size or fonts).
Rather than check the colour can you check some other feature of the UI control for the image? If the green image is not shown then what is shown instead? Try using the crosshairs tool to inspect the green image and also to inspect any other images shown in the same place. Hope to find some properties to distinguish the green image from the others.
You could request the developers to add some distinguishing features. If they do not want to then ask them how a screen reading program for sight impaired people would be able to tell the difference between the images.
For checking colours of UI controls you could capture and image of the controls and then examine the colours used in the image. To get the image use code based on
Image img = this.UIMap.UIYourApplicationsWindow.UISubWindow.UISubSub.CaptureImage();
When testing an application with a page save message, we had an error message that was always there, but was either colored red or not to make it visible or not. I found that the filter property controldefinition had reference to the color of the control. Could you look to see if the color is mention in any of the properties? If not AdrianHHH's answer is your best bet with coded ui.
Sikuli could compare the image if you want to run a little sikuli script from your coded ui test.

transparent tab control appears white

Anyway, I'm having a little difficulty with tab control. When I drag a new tab control onto a form, it appears white, rather than the grey (system colour) I was expecting.
When I look at the properties, its colour is set to web-transparent. Ok, so it should be transparent then (it isn't letting anything behind it show through). Setting the tab control back colour manually back to the system grey kind of works, but the tabs at the top still show as white. I'm assuming I could somehow change their colour as well, but I'm quickly getting into the realms of changing so many values from default, I'm clearly missing something type territory. I've googled every varient of "transparent tab control draws white" as I can, and although I found something to do with windows profiles, this seemed mostly confined to access 2003 using the vb you got access to in access.
I'm looking for any explanation as to:
what I need to do to correctly use transparency with tab controls
what I'm mis-understanding as the purpose of transparency in tab controls
how to easily change all the colours of the appropriate parts of the tab control to not be transparent.
I'm looking at windows forms for an MCTS, so please don't give a "you should use X instead" type answer.
No, getting white is certainly normal. TabControl and TabPage are rendered with theme colors when visual styles are enabled. So that makes the tab page white on machines with the standard Windows theme.
Yes, the default BackColor of Transparent is very unusual. You most certainly will never get actual transparency with that, unless you count seeing the background of the TabControl as transparency. The logic is pretty convoluted, rather than trying to explain it I'll just paste the MSDN explanation:
The default value of the BackColor property is the value of the Control.DefaultBackColor property unless the UseVisualStyleBackColor and Application.RenderWithVisualStyles property values are both true and the Appearance property of the parent TabControl has a value of Normal, in which case the default value of the BackColor property is Transparent. Child controls that you place on the TabPage inherit the BackColor value by default, so this behavior causes the background of the child controls to render with the current visual style.
Changing the value of the BackColor property automatically sets the UseVisualStyleBackColor property to false. If you want the TabPage background to render using visual styles but you want the child controls to inherit a BackColor value that you specify, set the UseVisualStyleBackColor property after you set the BackColor property.

Categories