That doesn't really make sense as asked. ACan I change the color of substrings in a single variable without using richtext box?
String
is just text. It doesn't contain any information about how that text should be displayed unless it is interpreted as markup, e.g. RTF or HTML. You can instruct a Label
how to display the text as a whole, e.g. by specifying a font or colour, but variable formatting takes something more.TheCurrently I am using labels and want to give different color to a single string.
Label
does have a Content
property but then you'd need to assign something to that that could do the variable formatting. There's certainly no standard control that will allow you to load plain text and easily specify how it gets formatted. The RichTextBox
does it by loading RTF markup and interpreting that. Another option that is still not the simple magic solution you want but might be easier than RTF is to use some sort of web browser control and use HTML markup to format. That's a bit more human-readable than RTF and web browsers are read-only by default.Best of luck for your project... As there is a lot of work in my current project, I'll simply go with rtf.What's wrong with creating a class for your labels, and creating a template around that class of labels?
Or creating a template around your xaml labels if that's where you have then designed?
Anything you can do in a webbrowser control can be done in xaml. Your options in WPF are far from being limited, and in fact, you have a wide variety of ways to approach this in WPF. Nothing some independent search engines cant help with unless someone here has the time to show you an example using custom templates.
Frankly, if you are creating complex UI systems, I would suggest using a asp.net MVC app, and create a desktop wrapper for your web project. This is the most modern approach for developing stylish desktop UI systems today, which most developers are starting to undertake. I myself have been building projects like this for some time now.
I would provide you with an example as I have done in the past, except I am very busy as I am about to release one of my biggest projects of my career year-end. Start with custom templating.
Got any link online?Templating is easier. Research before you dive in.
Yes.Can I still use Xaml Templating for such operation?? @Sheepings