Is there a premade color palette in WPF - wpf

I am currently creating a basic text editor that has basic functions such as changing fonts and sizes.
I am currently trying to add color changing capibilities and I was wondering if there was any premade color pallettes already in the default libraries. I have looked around and have found that i can download premade palettes but i want to just stick to the default stuff.
If theres not a way my backup plan is just to load colour names into a combo box.
Also I am coding using .WPF and adding my items through the XAML with methods in C# classes.
Any comments or suggestions are appreciated.
Thanks!

A 'palette' suggests two things: a control to select and/or mix a color or a collection of colors that go together nicely.
For the first: http://www.google.nl/search?q=wpf+color+picker there a lots to pick from.
For matching colors have a look at http://kuler.adobe.com/ it allows you to create a set or copy an existing matching set of colors.

There is System.Windows.Media.Colors which is a set of well known colors.
See this StackOverflow answer for an example of how to load those into a combobox:

Related

Protecting custom inline elements in WPF RichTextBox

I'm currently spiking with the WPF RichTextBox before I decide whether or not it can be used in a project of mine.
What I need is to have elements of text representing various objects (other texts or objects), a bit like a WIKI but not quite. Clicking on such a text will make stuff happen, like navigating to other texts or providing additional options.
Anyway, as these little text bits represent other objects I would like to protect them but I have succeeded with this only in part: The user cannot position a caret inside such a text element and edit/delete it but it is still possible to make a selection and delete/replace it, including my custom elements.
Have anyone travelled down this road with the RichTextBox? My latest experiment was to simply record all custom text elements when being part of a selection and then restoring them after the (destructive) edit. That fell apart because I can't find a way to re-insert my custom inline elements (derived from the Run class). The only way I've found to programmatically insert a Run (based) element at a specified position (TextPosition) is via its constructor.
Well, any hints would be greatly appreciated.
You are really looking for a FlowDocument, not a RichTextBox.

Find all objects and reapply current styles in Silverlight/XAML

I'm working on customizing the appearance of a silverlight app on user-click and with some help have managed to swap out the Resource Dictionary and reapply a style to a button - where the reapplied style comes from the new Resource dictionary. This works but I need to make it scalable, since the whole app needs to be restyle with a single user click.
I reapply the style of the button with the following statement:
this.button1.Style = (Style)App.Current.Resources["ButtonTheme"];
The two things I want to do are:
Get a collection of all objects on the page (all buttons, text boxes everything)
Loop through them and reapply whatever is the object's current style (after swapping out the Resource Dictionary)
Help here greatly appreciated. Also, please tell me if there is a better approach altogether.
Many thanks
You need to remove the "old" theme from the resource dictionary and then merge in the new one
See this link and this
You don't need to do it manually.
Please take a look at this sample http://weblogs.asp.net/lduveau/archive/2010/05/31/dynamically-apply-and-change-theme-with-the-silverlight-toolkit.aspx

WPF Generic Search Box for a window (only View search no backend search)

I was thinking of ways to implement a generic View search. What I mean here is say a Window has many controls (including usercontrols,customcontrols, etc). I want to implement a generic search box on the top of window which searches any Text in the window and highlight them.
I wanted to know is there a generic way of doing this or has anyone tried such UI based search.
I was searching through internet and found some nice links like below::
http://khason.net/blog/search-and-highlight-any-text-on-wpf-rendered-page/ which says search and highlight any Text in WPF rendered page but it doesnt work when there are lot of UserControls and CustomControls.
I myself did some research and thought of going through the VisualTree,LogicalTree, etc but I did not find them satisfactory.
Some say do it using attached behaviors or by data binding but that also did not help me. Because even if i achieved search using this technique, the problem is highlighting. Say there are 4 TextBoxes having different background colors and I highlight background to Yellow when Text is found, I have no way of removing the highlighting when Text is not found because I don't know the previous background color of TextBox.
Ok , enough of my thoughts. I would like to simply accept I am going nowhere in my thoughts. So people I want some guidance in implementing UI search. Also if you people can tell me how I can make it generic, it will be useful!!

WPF - Managing styles and avoiding messy resource dictionaries

I've spent hours working on an application design in WPF and created a whole bunch of different styles along the way. But I noticed that I actually had just edited the styles in the SimpleStyles.xaml file and not a custom dictionary.
So, I started right clicking all controls I could find and selected "edit a copy" and created a copy in a custom resource dictionary. But then I found that alot of the controls are based on several styles. SimpleScrollViewer e.g contains both the thumb and probably more. This created a huge mess in the overall structure of styles in the entire project.
And thus, my question is as follows;
What should I think about when doing this project from scratch again?
Is it best to edit a copy of the SimpleStyles controls? Is there a tool of some sort to manage stuff like this?
Expression Blend will add a resource dictionary for the Simple Styles the first time you use a SimpleStyled control. For real world projects it is best practice to separate resource dictionaries by resource type and then functional area.
For example you will have horizontal resource dictionaries that fall into the following categories:
Brushes
Control Styles
Converters / Selectors
Since these are horizontal their filenames are pretty self-explanatory (e.g. Brushes.xaml, ControlStyles.xaml, Converters.xaml, etc.)
If you are using Silverlight you should probably think about using Themes. In which case you would create Brushes.xaml and ControlStyles.xaml for each [themeName]\generic.xaml you create.
Then you should create resource dictionaries for functional areas that will house the following things:
Item Templates for various ItemsControls used.
Content Templates for various ContentControls used.
One off Control Styles
Each functional area would have a resource dictionary that had the above items (e.g. CustomerManagementStyles.xaml, Orderingstyles.xaml, etc.)

Styling WPF slider background

I'm trying to apply a specific style to a slider control and I'm having trouble figuring out what I need to do for the slider's background. What do I need to do to get something like this triangle to show in the background of my slider?
I initially thought I would define a GeometryDrawing and set something in the tickbar tag to it - but I can't find anything suitable.
This is what I'm looking for. Thanks for any ideas.
Slider background http://img16.imageshack.us/img16/690/slider.png
Check out my Intuipic project, which does something similar (only horizontally):
you need to investigate a bit more into styling and templatiting in wpf. I would expect the easiest way would be to define a Control Template but you 'might' be able to achieve this with just styling
Check out this page on msdn for starters. There is probably loads of other resources out there. Big sections on it in the book i'm reading at the moment - pro wpf in c# 2008
Sorry i'm not coming up with an example... you'd be better off doing a bit of background reading and then coming back with any specific issues.

Resources