Change Caret Color in WinRT? - wpf

So in WPF and Silverlight you could set the caret color for TextBox using TextBox.CaretBrush, but in WinRT it seems in all their wisdom they removed this property. So now if the TextBox is a dark color, since it defaults the caret color to black you can't see it, and if the background color of your TextBox is black the caret ceases to exist completely. I find this completely illogical, there has got to be a way to change the caret color, either pragmatically or something?
Does anyone have any ideas?

This is not possible. You need to switch your TextBox to light background when it has focus so the caret is visible.

A little late to the party on this question but I ran into the same issue and found an easy work-around. On the Windows 8.1 RT preview I noticed that overriding the TextBoxForegroundThemeBrush changes the caret or cursor color for TextBox.
<SolidColorBrush x:Key="TextBoxForegroundThemeBrush" Color="#FFFFFFFF" />
Typically the cursor is always black, even when you override the Style and ControlTemplate. I happened to stumble on this by looking in the ThemeResources.xaml that Filip mentioned above. I'm not sure if this applies to pre-8.1 xaml, Microsoft seems to have cleaned a lot up in new SDK.

I got this working by overlaying a transparent canvas overtop of the TextBox, using SelectionStart and GetRectFromCharIndex to obtain coordinates, then on KeyDown, KeyUp, and MouseDown I set the coordinates of a Line and use a TranslateTransform to move it, works great and performance is fantastic!
Not sure why I didn't try this first, I've done Transforms in Silverlight and WPF many times prior. I guess the subtle differences in WinRt kind of threw me for a loop...

Related

Change border brush from skyblue in wizard control of extended wpf toolkit

I'm using Wizard control of Extended wpf toolkit package.
I would like to change color of the border. See sky blue in image below:
I tried set broder brush\background to wizard\wizard page\window controls, but it failed.
Anybody know how to change it?
Your assistance is appreciated!
Now that you have provided more info, I can see that your question title does not match what you asking to change. You are not asking to change the color of the border of the Wizard Control, you are asking to change the color of the WPF Window.
It takes some time to get things right, and I highly discourage doing this if you app will be used by people with disabilities, who need high contrast, who customized their desktop to a certain color because of color blindness, and the list goes on...Microsoft has worked very hard to address such issues with the defaults.
BUT...you can change this by restyling your Window Style. You can find plenty of code examples.
Here are two:
Can i set the window border color in WPF?
How can I style the border and title bar of a window in WPF?

wpf how to create a custom button

In WPF how do I make a button with a white border with a 5 pixel radius, a dark gray background and white text? It would be nice if it still had all the mouse over and ispressed effect too.
You would need to understand how Control Templates work in WPF. This sample on applying Control Templates on button by MSDN should get you started.
There's is also a similar SO QA that should help you.

Dark Background of new WPF Ribbon becomes gradient?

I am using the new Version of MS WPF Ribbon (Version MS WPF Ribbon 3.5.40729.1) with Windows 7 and I am trying to change the Background of the Ribbon. Everything looks fine if I use light background colors.
But e.g. if I choose "Black" a white gradient is shown with the black. It does not seem to be possible to remove the white and simply have a black background. And it looks ugly, especially when every Textcolor normally is white. (Tabheaders get white background and are not readable anymore)
In the samples, (I leave everything as is) if I set Background=Black directly in the ribbon's property, the effect is the same.
What do I have to set or do to get rid of the white gradient color?
There's a hard-coded gloss effect in the RibbonGroup template. It's lame, but the only way to get rid of it is to override the temlate for RibbonGroup. If you have Blend, just extract the template and rip out the offending LinearGradientBrush.

Silverlight 4: how to highlight control on mouse over

My aim is to get fine control "animation" when it is mouse-over-ed. For example, I have a "map" of controls (game map that represent different type of terrain), each of them is an image with trees/rocks/hills on the green grass or water (lake or see) image of blue/cyan color. When user point any image with mouse it should get shiny: either get more bright background or get a shiny border.
It is hard to say what exactly I want to have (either background change or border), I would like to try each of them and see what is the most appropriate for me.
I am going to have a custom control (MapTile) that will represent a map tile. I know how to catch MouseEnter/MouseLeave events, but not sure how to change control style and if it is a good idea to work with control style in CodeBehind, probably there are better XAML-based solutions.
Could you please help with a solution that provide few goals:
Goal1: Add highlighted border around the control (it will be squares/rectangles, or circles; use what is easier) on mouse enter, remove border on move leave;
Goal2: Change some properties of my CustomControl (for example, background color).
Thank you very much!
1. How to han
You might find it easiest to get hold of Expression Blend and use it to create a custom template for your control.
The Learn Expression Blend page would be a good place to start. Look for tutorials on customising buttons and this is the same sort of thing that you want to do.
You need to use an attached behavior on your control. You don't need to learn Blend for this.
Check this one as an example, but you can search the site for Mouse Over for other examples.
http://gallery.expression.microsoft.com/en-us/MouseOver3D

DropShadowBitmapEffect Doesn't work on TextBlock

Does anyone know why the DropShadowBitmapEffect and the EmbossBitmapEffect won't work on a TextBlock (not textBOX) in WPF? OuterGlow, Blur and Bevel seem to work fine.
The transparent background brush is apparently not the answer because you can get a dropshadow with a null background brush. The default softness on a dropshadow is 50% and if you have a small font, the softness dissipates the shadow too much. There seems to be a steep drop off around softness of 39% (at which point the shadow more or less disappears). Try setting it to 0 and slowly moving you're way up until you find a number that still shows the shadow.
Yet another note: the softness is definitely a factor, but be aware in Xaml the valid values are really only 0 to 1, but in Blend it shows it as a percentage up to 100. So if you set the value to 100 in Xaml, it will be completely dissipated.
The background brush = transparent solution still may work for the embossing effect
Bitmap effects work by looking at the post-rendered pixels and running standard image manipulation on them. It should only be dependent on the color of the pixels. I wonder if their algorithms don't work well on white. Try changing the color to see if that has an effect -- if it does, you might want to try putting a black panel underneath with drop shadow set on it.
Edit: The questioner found the answer
"Thanks for pointing me in the correct general direction. It wasn't the color of the text or the DropShadow that mattered, what is needed is to make the Background Brush on the TextBlock the Transparent Brush (Alpha = 0) instead of null."
Important Sidenote: you shouldn't really be using BitmapEffects any more. Use the Effect property based on ShaderModel effects introduced in .net 3.5 SP1, it uses hardware rendering and has far better performance.
More Information

Resources