Solved

Wpf Listview text formatting

Posted on 2012-03-12
1
687 Views
Last Modified: 2012-03-23
Hi!

Is it possible to format text in wpf listview  i.e i have one cell that contains name and title.

i would like to have the name in BOLD and little bigger font size than the Title in the same cell.  

like this with a linefeed

Firstname SecName   --BOLD and 2 sizes bigger
CEO of xxxxxxx   smaller and perhaps Italics
0
Comment
Question by:jamppi
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 96

Accepted Solution

by:
Bob Learned earned 250 total points
ID: 37710910
I would say that you could use a TextBlock in the ListBox item template, with different Run elements that have different styles applied.

XAML example:

<TextBlock.Inlines>
            <Run FontWeight="Bold" FontSize="14" Text="This is WPF TextBlock Example. " />
            <Run FontStyle="Italic" Foreground="Red" Text="This is red text. " />
            <Run FontStyle="Italic" FontSize="18" Text="Here is some linear gradient text. ">
                <Run.Foreground>
                    <LinearGradientBrush>
                        <GradientStop Color="Green" Offset="0.0" />
                        <GradientStop Color="Purple" Offset="0.25" />
                        <GradientStop Color="Orange" Offset="0.5" />
                        <GradientStop Color="Blue" Offset="0.75" />
                    </LinearGradientBrush>
                </Run.Foreground>
            </Run>
            <Run FontStyle="Italic" Foreground="Green" Text="How about adding some green? " />
        </TextBlock.Inlines>

Open in new window

0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question