Silverlight: How to style the validation tooltip? - silverlight

I did some searching but it wasn't what I was looking for. So, does anyone know a way how to style the validation tooltip in Silverlight(the thing in the green border)?
alt text http://img689.imageshack.us/img689/222/validationtooltip.png
Any help would be greatly appreciated!
Best Regards,
~K

Unfortunately you can't easily provide a style for the validation tooltip without effectively styling the entire Textbox control. Blend makes this fairly easy if you are familiar with using that design tool. However if your a dyed in the wool coder like me then...
Goto this page on MSDN TextBox Styles and Templates
Copy the vsm namespace alias to your UserControl xaml
Copy the TextBox style into UserControls.Resources give it at an x:Key name (say MyTextBoxStyle")
Copy the ValidationToolTipTemplate from the web page to the UserControls.Resources, paste it above the TextBox style. It already has an x:Key name that the TextBox style will be referencing.
Add Style="{StaticResource MyTextBoxStyle}" to your TextBox in the data grid.
Now you play around with the validation elements of the templates to get your desired result.

The validation messages are displayed as a visual state. you can get to these (and edit them) as templates directly from blend.

Related

WPF Listview Gridview styling column header presenter

I am making a style for gridview in WPF which consists of several parts, currently I am stuck with the column headers part
I made a style for GridViewColumnHeader but now I need a style for its container
is there a part similar to "DataGridColumnHeadersPresenter" which is a wrapper for all of the columns?
Any help where to find the parts of the control? I want to find the name of that part and the default template for it.
Thank you
Another reason why Snoop is very good.
You get Snoop to identify the element your looking for
Guess it's GridViewHeaderRowPresenter what your looking for.

XAML: Is there a way to style TreeViewItem header property to contain multiple font styles?

I need to create a TreeView type controller that will display rich text.
Example:
» Signed by Person Name
» Certified by Person Name
Content of the TreeViewItem is easy as I can simply put TextBlock inside, but header don't allow for multiple font style declarations.
I'm really a beginner in XAML and I work in ExpressionBlend (although I don't shy away from coding). I would really appreciate if someone push me into right direction.
You can put a "Run" in a TextBlock to change the font.
e.g.
<TextBlock>Hello<Run FontStyle="Bold">World</Run></TextBlock>
You can set the content of the header to anything you want
<TreeViewItem>
<TreeViewItem.Header>
<TextBlock>Hello<Run FontStyle="Bold">World</Run></TextBlock>
</TreeViewItem.Header>
</TreeViewItem>
When you do this:
<TreeViewItem>Hello</TreeViewItem>
You are not telling the XAML parser what property you want to put 'Hello' into. The XAML parser will look at the type (TreeViewItem) and see which is set as the 'ContentProperty', in this case it's the property called 'Header'. Because you have not specified what 'Hello' is, it assumes a string. Since a string can't actually be displayed as content in WPF, it has to create a control to display the string. The ValueConverter for TreeViewItem is set up to provide a TextBlock control and set the Text of this control to the string you entered. So what's happening behind the scenes is a lot more than you can see :)
All of this stuff you can do with your own controls
You should probably read up on WPF templating, content controls, content presenter, styles etc. There are a lot of powerful things you can do with WPF - for instance, make every single button in your application have the same layout and style and add an image to the front of the button without any code (just with a few lines of XAML)
Have a look here for a beginners guide to templating
http://msdn.microsoft.com/en-us/magazine/cc163497.aspx

Restyling ComboBoxI dropdown gray and not selectable when ComboBox is ReadOnly

I have seen this post: WPF ComboBox: background color when disabled
and some others...
But This solution causes me some problems. All I want is to make the textBox gray, and the ComboBoxItems gray and not selectable. I don't want to recreate all the style as the control won't work properly on both XP and seven. I don't want to choose one style for both, but I want XP style for XP and seven style for seven.
Is there a way to set the style so I can change the Background of the ComboBoxItems when the comboBox is Readonly?
Thanks in advance!
Update: It seems that the Drop down popup should be restyled instead. I got to find how.
I finally found my answer at many places on the web, pieces by pieces. The ComboBox style is composed of other controls. The PopUp is the one that interests me. It is not public, so I can't modify it as I want. It would have been interesting to define a style for my popup and to replace the original popup by it, but it is not accessible, so... I attempted to make a template that inherits from the template of the original ComboBox, but that is not possible neither. It won't accept inheritance for some good reasons How to Inherit a Control Template. So the template must be remade totally or not. The other option would be to make my own control that inherits from combobox and that changes the items to gray and not selectable when the combobox is readonly (into the code), but this is not a good idea in my situation. No solution for me. I will have to stick with the whole template redifinition. I hope this post will help someone in some way!

Is there a way to quickly create a style from a set of selected attributes?

I currently want to create a wpf style by selecting a group of attributes, e.g. Height, Width of a button, then right click and call a command like "Generate style from selection" and the IDE will do the rest for me: add .Resource tags, and a Style with sample x:Key and put the attributes' names and values into Setter tags.
Is it possible? Any addons are welcome. I prefer to have a free solution. Please discuss!
If you have Expression Blend at your disposal, creating a new style is fairly simple. Just a matter of stubbing out the style in code
<Style x:Name="MyStyle" TargetType="{x:Type TextBlock}"/>
Open the Resource browser, select the style you just made, and then use the properties box to set the properties.
As for Visual Studio, I have not yet seen a WPF extension that would do it even this automated. The XAML designer in Visual Studio leaves a lot to be desired for me, and one of the reasons is the style creation.
Blend has style visualization, VS2010 does not. Any styling stuff that I do, is in Blend.

Changing the style of a Combo-Box in WPF (in Blend preferably)

I'm having some issues trying to change the look / style of a combo box in Expression Blend / WPF. While there are tutorials out there describing setting styles for buttons, there seem to be a few wrinkles with ComboBox controls.
Can anyone offer any advice, or point me towards good tutorials that cover re-styling something more complex than a button?
The ComboBox style template has 3 parts to it.
The ContentPresenter you should have come across styling Buttons.
There is a Part_Popup that you should find easy to change properties on and style.
The last part is a ToggleButton, to style that you need to "edit a copy" again and create another new style template for the ToggleButton.
Have a look at BeaCostas SolarSytem Listbox it's a lovely piece of work.

Resources