.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

How to set the text colour for all controls within a content presenter.

Posted By:      Posted Date: October 12, 2010    Points: 0   Category :WPF


In my application I have a custom content control tha I use many times. How can I set the foreground colour (for Text) for all controls that appear inside this control??  Id like to be able to set this once and for it to apply to all the controls that have text (ie textbox,radiobutton, label etc). I dont want to have to set the foreground property for each control defined.

Initially, I thought I would be able to use the Attached property TextElement.Foreground on the content presenter of the custom control however this doesn't work,not sure why either as TextElement.FontSize does work.



View Complete Post

More Related Resource Links

SharePoint and Open XML: Generating Documents from SharePoint Using Open XML Content Controls


This article describes how to generate documents that contain data stored in SharePoint lists. The example demonstrates how OpenXML content controls can be defined to capture list data in a Word document and how LINQ to XML can be used to query the lists. The documents are generated from a SharePoint Web Part.

Eric White

MSDN Magazine October 2009

Text Rendering: Build World-Ready Apps Using Complex Scripts In Windows Forms Controls


The System.Windows.Forms.TextRenderer class provides support for complex scripts in Windows Forms controls so you can render text the way you want and support international locales.

Miguel A. Lacouture

MSDN Magazine March 2006

Change label text on master page from the content page.

Hello. Can I access the objects (for example change the label text) on the master page, from its contents page code? If yes, how can I approach that? Thank you Artashes

Page has one or more controls that do not correspond with con

I'm posting this in VS 2008 forum since I wasn't getting this error when this was in VS 2005.  It's complaining about my content tags but I have not a clue why, everything looks fine to me.  I've included the master page so what's the deal? <%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Sub.master.cs" Inherits="Web.MasterPages.Sub" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head id="Head1" runat="server"> <title id="Title" runat="server" /> <link id="main_styles" href="~/main.css" rel="stylesheet" type="text/css" /> <style type="text/css"> body { background-image: url(images/back.jpg); } .style1 {color: #B92722} #bigImg { position: absolute; display: none; } </style> </head> <body class="Mainbody"> <form id="form1" runat="server"> <!-- Main Table --> <div class="centered-table"> <table width="100%" border="0" cellspacing="0" cellpadding="0"&g

DataTrigger - Binding Value Property to Target Controls Content Property

This Gives me an error..   <Style x:Key="radioButtonSelctionKey" TargetType="{x:Type RadioButton}">       <Style.Triggers>       <DataTrigger Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type UserControl}},Path=ValueText}" Value="{Binding Path=Content}">       <Setter Property="IsChecked" Value="True"></Setter>       </DataTrigger>       </Style.Triggers>       </Style> Is it valid to bind Value Property. If not then does it mean that the Value propety must always fix and can not be changed or Bound to any property Dose it mean that both of the way of setting Value proeprt are WRONG..? 1) Value="{Binding Path=Content}"> Or 2) Value="{Binding RelativeSource={RelativeSource Mode=Self},Path=Content}">

XAML - Sum controls content.

In a Gridview line with 3 textboxs, the user enters a quantity in the first txtbox, the second already contains the unit price. What is the best way to generate the total in the last textbox and also sum columns in the grid footer? The Gridview is bound to a CollectionViewSource.

Remove Word Style once copy and paste content to Rich text Editor in sharepoint 2010

Hi Guys, I have page layout for Users to add content for Page.I have site column for page content on field type HTML with Richtextmode="FUll Html". Now when user cut and paste content from Word document in this Field it carry word document style. how can i control this content on Page layout with CSS. Please adviseThanks Ron

Reading WPF rich text box content in HTML format

Hi, I am using WPF RichTextBox. From that, I am reading the content in RTF format using the following code. TextRange textRange = new TextRange(paramRichTextBox.Document.ContentStart, paramRichTextBox.Document.ContentEnd); MemoryStream msData = new MemoryStream(); textRange.Save(msData, DataFormats.Rtf); //get the data from the selected range //strData = textRange.Text; strData = ASCIIEncoding.Default.GetString(msData.ToArray()); I also found that there is an option called DataFormats.HTML. Hence, I tried using this but ended up with error. Is there any other way to read the content of RichTextBox in HTML format? Thanks in Advance!!! Best Regards, Subalakshmi Vijayarajan.

How do I dynamically change and display the group of controls/content in wpf

The requirement for me is, based on some condition I need to show different group of controls on the screen. Gow do I achive this?

HTML Content into Text


Hey all,


is it possible to convert html into text in a field?

I've got e-mails in my report where it is html and I would need to print and display it without html.




Accessing master page controls from content page formview



I have a master page with a textbox that I want to use for a search, and display the results on the content page.

I've dragged in the datasource to the content page, and configured the formview to use that datasource... almost.

The issue I'm having is that on the last step of the configure datasource wizard where you select the parameters, I want to select the master page textbox control for the search parameter... but of course it's not available in the list. The list only allows me to choose controls from the content page.

How do I set this master page search box as the parameter for my datasource?

Any ideas would be much appreciated!



WCF returning "The content type text/html of the response message does not match the content type of

I have a WCF service I am trying to run on a new installation of 64-bit Windows Server 2008 IIS. Although it runs fine on Windows 2003 IIS, it is throwing the error in the thread title, which appears to be a server config issue, but I am not sure. Googling and searching the MSDN forums did not turn up a solution. I tried running WCF Logging, but that didn't help either.

Does anyone have any suggestions on how to solve this probelm?

Here is the error:

The content type text/html of the response message does not match the content type of the binding (application/soap+xml; charset=utf-8). If using a custom encoder, be sure that the IsContentTypeSupported method is implemented properly. The first 1024 bytes of the response were: '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<meta http-equiv="Content-Type" content=&qu

How to save WPF RichTextBox content (text + image) to the database



I want to save (and after that also to retrieve) the content of an WPF RichTextBox (text + image) to/from the database.

I found this: http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/750a654e-b002-4742-8f46-609e93f6ec81 but like the author said, the solution seams not to work for text with image - the image is ignored/removed and only the formatted text is saved and after that retrieved to/from database.

Know someone a solution about this issue?

Best regards,





Only Content controls are allowed directly in a content page that contains Content controls


Hello Everyone,

  I am getting this error "Only Content controls are allowed directly in a content page that contains Content controls". I am using a single aspx page and not a separate cs file. Now, to write code inside aspx page, I am using <script> tag. Now, my problem is inside one of the method I have to use <script> tag. Now, when i use that this error comes. Eg

  <script runat="server">

 ........inside it coding done

  // Method inside which I have to use this tag again

  public void abc()


........initially some code.........

Response.Write("<script>document.getElementById('PaylForm').submit();</script></body></html>");   //This gives error




Thanks in Advance.

C# data bound combobox: display selected item text in separate label.content


I am new to C# but I'm resisting the urge to run screaming back to VB.NET. I'm working with a WPF application using C# code-behind and a lot of binding to a SQL 2005 database backend.

GOAL: I have a comboBox bound to a tbl_Systems entity which provides a list of systems for user selection. When the User selects a system from the comboBox I want to display the selection's text in a separate Label. The big picture is that several comboBox selections will be used to build a query string that will populate a listbox. So, I want to display these selected values in the Label so the user can see the query string they have dictated.

PROBLEM: When I set the Label content property to the comboBox SelectedItem property the entity tbl_System is displayed in the Label not the comboBox selection text.

SUSPICION: From reading similar examples in VB I suspect that the comboBox SelectedItem is actually a "datarowview" or the C# equivalent. But I don't know how to translate this explanation to C#.

The UI XAML comboBox properties are set as such:


restrict rich text box to certain fonts and colours in content editor web part - Sharepoint 2010 -




Just wondering if anyone knows a way to make only certain fonts and colours available to rich text box in the content editor web part?

also is there a way to make only certain features available in the rich text box, ie only let the users change font, but not let them use bullet points etc.




remove html tags from that text being extracted from html content


Hi there

I have been trying to extract text from the html content ,But, had resulted with some html tags within the extracted text  , what i should i do in order  to extract only plain text wothout having too much tags or stricpts , i am testing  on differents webpages,so html elements are unknow or chagnes from time to time .i am using Html Agility Pack also . here some of code

HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();

  doc.Load(new StringReader(result));

   HtmlNode bodyNode = doc.DocumentNode.SelectSingleNode("//body");

   string results  = bodyNode.InnerText.ToString();

regex code
         public string removehtmltags_Regex(string source)
            return Regex.Replace(source, "<.*?>", string.Empty);
   result from this code ,


2:59:46 PM: var _GlobalNavHeaderUtf8Encoding=true;var includeHost="http://include.ebaystatic.com/";Skip to main contentBuyMy eBaySellCommunityContact usHelpBasketBasketvjo.darw

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend