RichTextBox Binding to a String or something else

Hello.
First, I'am from Germany and I have to learn english and this is the reason, why I wrote my question in english.
My problem is: I want to bind a RTF to a String or something else, to work with the informations in behind code.
But after I searched to get more informations about this, I got 2 codes which should help me to bind a FlowDocument to a RTf.
/*This simply takes the string and reads it line by line. If we have the desired characters at the end of a line (“:.”),
* then we make the line blue and bold and remove the characters, otherwise we just add the text.
* Each line is added as a paragraph so to reduce the space between each one.
http://www.codeproject.com/Articles/137209/Binding-and-styling-text-to-a-RichTextBox-in-WPF*/
protected Object Convert(Object value, Type targetType, Object parameter, CultureInfo culture)
FlowDocument doc = new FlowDocument ();
String s = value as String;
if(s != null)
using ( StringReader reader = new StringReader ( s ) )
String newLine;
while ( ( newLine = reader.ReadLine () ) != null )
Paragraph paragraph = null;
if ( newLine.EndsWith ( ":." ) == true )
paragraph = new Paragraph ( new Run ( newLine.Replace ( ":.", string.Empty ) ) );
paragraph.Foreground = new SolidColorBrush ( Colors.Blue );
paragraph.FontWeight = FontWeights.Bold;
else
paragraph = new Paragraph ( new Run ( newLine ) );
doc.Blocks.Add ( paragraph );
return doc;
public class BindableRichTextBox : RichTextBox
public static readonly DependencyProperty DocumentProperty = DependencyProperty.Register ( "Document", typeof ( FlowDocument ), typeof ( BindableRichTextBox ), new FrameworkPropertyMetadata ( null, new PropertyChangedCallback ( OnDocumentChanged ) ) );
public new FlowDocument Document
get
return (FlowDocument) this.GetValue ( DocumentProperty );
set
this.SetValue ( DocumentProperty, value );
public static void OnDocumentChanged ( DependencyObject obj, DependencyPropertyChangedEventArgs args )
RichTextBox rtb = (RichTextBox) obj;
rtb.Document = (FlowDocument) args.NewValue;
But know I have no idea, how to work with this code. 
Can maybe anyone help me?
Tom

I don't see any binding in that code you posted there.
You can bind the content of a run.
<Run Text="{Binding someProperty}"
And you can create a binding like that in code.
https://msdn.microsoft.com/en-us/library/ms742863%28v=vs.110%29.aspx?f=255&MSPPError=-2147217396
I'm not sure what you have as a viewmodel or whatever to bind to that but you can also manipulate xml into xaml which would be one way to build a document had many runs, paragraphs and bindings.
The dynamic xaml series of articles linked in my sig does that kind of manipulation to generate UI from xml templates. You could use a similar technique - none of those articles do exactly what you're after I'm afraid.
Hope that helps.
Recent Technet articles:
Property List Editing;  
Dynamic XAML

Similar Messages

  • How can i send mail to the yahoo mail or gmail or something else

    hello guys,
    i want to know how to send mails to the yahoo or gmail or something else.i heard that we have to change some smtp address and some port number. can any body suggest me to get that.please help me
    any replies will be appreciated greatly.

    Hi chnaresh,
    This is the code I use to send mail, it's not specific to gmail, but it works. The "props" object expects the usual mail properties, "mail.smtp.host", "mail.user" or "mail.smtp.user", as well as "mail.smtp.ssl" which you'd want to set to "true" if you're using gmail. It also expects "mail.smtp.passwd" or "mail.passwd" which my gut tells me is unsafe, but I'm not sure why.
    Good luck,
    radikal_3dward
    public static int sendMail(final Properties props, String subject, String body, String to, String cc, String bcc, String from, File[] attachments, boolean toStdOut)
    throws javax.mail.internet.AddressException, javax.mail.MessagingException, javax.mail.NoSuchProviderException
    Session sess;
    //props.setProperty("mail.debug", "true");
    if(props.getProperty("mail.smtp.ssl") != null && props.getProperty("mail.smtp.ssl").equalsIgnoreCase("true"))
    Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
    String portStr = ((props.getProperty("mail.smtp.port") != null) ? (props.getProperty("mail.smtp.port")) : "465");
    props.put("mail.smtp.auth", "true");
    props.put("mail.smtp.socketFactory.port", portStr);
    props.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
    props.put("mail.smtp.socketFactory.fallback", "false");
    sess = Session.getDefaultInstance(props,
    new javax.mail.Authenticator()
    protected PasswordAuthentication getPasswordAuthentication()
    String userName = ((props.getProperty("mail.smtp.user") != null) ? props.getProperty("mail.smtp.user") : props.getProperty("mail.user"));
    String passwd = ((props.getProperty("mail.smtp.passwd") != null) ? props.getProperty("mail.smtp.passwd") : props.getProperty("mail.passwd"));
    if(userName == null || passwd == null)
    return null;
    return new PasswordAuthentication(userName , passwd);
    else
    String portStr = ((props.getProperty("mail.smtp.port") != null) ? (props.getProperty("mail.smtp.port")) : "25");
    sess = Session.getInstance(props, null);
    //sess.setDebug(true);
    MimeMessage mess = new MimeMessage(sess);
    mess.setSubject(subject);
    StringTokenizer toST = new StringTokenizer(to, ",;");
    while(toST.hasMoreTokens())
    Address addr = new InternetAddress(toST.nextToken());
    mess.addRecipient(Message.RecipientType.TO, addr);
    if(from != null)
    StringTokenizer fromST = new StringTokenizer(from, ",;");
    InternetAddress[] fromAddrs = new InternetAddress[fromST.countTokens()];
    for(int i = 0; fromST.hasMoreTokens(); i++)
    fromAddrs[i] = new InternetAddress(fromST.nextToken());
    mess.addFrom(fromAddrs);
    if(cc != null)
    StringTokenizer ccST = new StringTokenizer(cc, ",;");
    while(ccST.hasMoreTokens())
    Address addr = new InternetAddress(ccST.nextToken());
    mess.addRecipient(Message.RecipientType.CC, addr);
    if(bcc != null)
    StringTokenizer bccST = new StringTokenizer(bcc, ",;");
    while(bccST.hasMoreTokens())
    Address addr = new InternetAddress(bccST.nextToken());
    mess.addRecipient(Message.RecipientType.BCC, addr);
    BodyPart messageBodyPart = new MimeBodyPart();
    Multipart multipart = new MimeMultipart();
    if(body != null)
    messageBodyPart.setText(body);
    multipart.addBodyPart(messageBodyPart);
    if(attachments != null)
    for(int i = 0; i < attachments.length; i++)
    messageBodyPart = new MimeBodyPart();
    DataSource source = new FileDataSource(attachments);
    messageBodyPart.setDataHandler(new DataHandler(source));
    messageBodyPart.setFileName(attachments[i].getName());
    multipart.addBodyPart(messageBodyPart);
    mess.setContent(multipart);
    Address[] allRecips = mess.getAllRecipients();
    if(toStdOut)
    System.out.println("done.");
    //System.out.println("Sending message (\"" + mess.getSubject().substring(0,10) + "...\") to :");
    System.out.println("Sending message (\"" + mess.getSubject() + "...\") to :");
    for(int i = 0; i < allRecips.length; i++)
    System.out.print(allRecips[i] + ";");
    System.out.println("...");
    Transport.send(mess);
    if(toStdOut)
    System.out.println("done.");
    return 0;

  • I believe for the year I have not been using photoshop photography but something else so I never really used it or photoshop photography ..can you check for me

    now that I just re-newed my photoshop photography ....I have not been using that for some reason I have been using something else. they had changed me a couple
    of times last year from one thing to another ...so I never go photoshop photography downloaded. I used the other one very little because I wasn't sure I should...gee
    I hope that makes sense.
    I need to download photoshop photography.
    Sherri nicholas

    You need to get the owner's manual for your Ford's bluetooth system to see how to put your system into discovery mode for the iPhone as well as the appropriate steps to take. 
    In addition, you should see if the iPhone is supported.

  • Downloading a file would bring up an option to open the file or save it - for some reason now it just downloads straight to the download folder. Why? Problem with Firefox or something else?

    Downloading a file would normally bring up an option to open the file with the appropriate program or save it - for some reason now it just downloads straight to the download folder. Why? Problem with Firefox or something else? It's very frustrating - sometimes you want the file opened first so it can be discarded or saved to a different location.

    Hey. that's great! Thanks for posting back with the outcome.

  • On some pages the text from more than one paragraph stack up on top of each other, like writing something then writing something else on top of it.

    On some pages the text from more than one paragraph stack up on top of each other, like writing something then writing something else over the top of it. Some pages will run text and pictures together, like a car rear-ending another or a train pile up. Other pages will cut an image or text short, i.e. it will display a portion of the top of the image or text but not the rest. This happens on Amazon for example, the section where it says "Customers who looked at this also looked at" will allow only a certain amount of the upper portion of the description immediately below the picture of the product but below that section everything is fine until I get to another section displaying more products and their descriptions and then it cuts the bottom portions off again. I've noticed this behavior mostly in the sections with product photos, the text sections seem okay. YouTube also displays this behavior. It's even doing it on this page right now. Below this box I can read "The more information you can provide the better chance your question will be answered " , but directly below that in the next sentence I can see the start of it with "Troublshootin" and the "Automatically Add" in a green field covering the "g". The next clear text is "A window will open in the top corner. Click Allow, and then click Install. If the automated way doesn't work, try these manual steps." I tried turning of pre-fetching, clearing history, cookies, and cache, scanning for malware with Avast and Windows Defender all to no avail. It began when I upgraded from dial up to DSL via AT&T Uverse. I have a Motorola NVG510 modem. The modem was replaced an hour ago along with new dedicated lines and DSL/Phone splitter from the box by an AT&T technician to make sure my incoming lines were up to par. He ran a connection test and verified everything is up to standards. IE does not display this behavior. I am running Firefox20.0.1 and all previous versions have acted the same way since I upgraded to DSL about 3 months ago.

    If you have increased the minimum font size then try the default setting "none" in case the current setting is causing problems.
    *Tools > Options > Content : Fonts & Colors > Advanced > Minimum Font Size (none)
    Make sure that you allow websites to choose their fonts.
    *Tools > Options > Content : Fonts & Colors > Advanced: [X] "Allow pages to choose their own fonts, instead of my selections above"
    It is better not to increase the minimum font size, but use an extension to set the default page zoom to prevent issues with text not being displayed properly.
    You can use an extension to set a default font size and page zoom on web pages.
    *Default FullZoom Level: https://addons.mozilla.org/firefox/addon/default-fullzoom-level/
    *NoSquint: https://addons.mozilla.org/firefox/addon/nosquint/

  • My mom put my ipod 5th gen in the house somewhere and it was turned off. It is connected to the internet in the house. How do i turn it on with the Findmyiphone or something else? It was an expensive gift and we can't find it now! Please help!

    My mom put my ipod 5th gen in the house somewhere and it was turned off. It is connected to the internet in the house. How do i turn it on with the Findmyiphone or something else? It was an expensive gift and we can't find it now! Please help! How do i turn it on without finding it because she can't remember where it was.

    That is so dumb...Apple is the best and most techinological company IN THE WORLD and they don't have the time to invent something like that? HUH? All they are worried about is making the "Worlds best Phone" and they can't take the time out to help their users or anybody that has their products. All they have is "Find mt Iphone" Well they should step up and do something else to help people like me out. Find a way to turn it on and you can find it or find a way to turn it on remotely.
    Thank you for your replys

  • How does Azure Compute Emulator (or the Azure one) determine if a role is web project or something else ("The Web Role in question doesn't seem to be a web application type project")?

    I'm not sure if this is F# specific or something else, but what could cause the following error message when trying to debug locally an Azure cloud service:
    The Web Role in question doesn't seem to be a web application type project.
    I added an empty F# web api Project to a solution (which adds Global.asax etc., I added an OWIN startup class Startup etc.) and then from an existing
    cloud service project I picked Roles and
    chose Add
    -> Web Role Project in solution, which finds the F# web project (its project type guids are 349C5851-65DF-11DA-9384-00065B846F21 and F2A71F9B-5D33-465A-A702-920D77279786),
    of which the first one seem to be exactly the GUID that defines a web application type.
    However, when I try to start the cloud project locally, I get the aforementioned error message. I have a C# Web Role project that will start when I remove the F# project. I also have F# worker
    role projects that start with the C# web role project if I remove this F# web role project. If I set the F# web project as a startup project,
    it starts and runs as one would expect, normally.
    Now, it makes me wonder if this is something with F# or could this error message appears in C# too, but I didn't find anything on Google. What kind of checks are there when starting the emulator and which one needs
    failing to prompt the aforementioned message? Can anyone shed light into this?
    Sudet ulvovat -- karavaani kulkee

    Sudet,
    Yeah you are right, the GUID mentioned seems to be correct and the first one i.e. {349C5851-65DF-11DA-9384-00065B846F21} means the web application project which compute emulator uses to determine while spawning up role instances.
    You might want to compare the csproj of your C# and F# web projects which might give some pointers.
    Are you able to run your F# web project locally in IIS? If yes then you will definitely be able to run it on azure so I will recommend to test it in IIS Express first.
    Here are some other tips which you can refer or see If you are yet to do those settings
    1. Turn on the IIS Express - You can do it by navigating to project properties
    2. Install Dependent ASP.NET NuGets / Web Api dependencies (If there are any missing), Reference System.Web assembly
    Also I will suggest to refer this nice article about how to create a F# web Api project
    http://blog.ploeh.dk/2013/08/23/how-to-create-a-pure-f-aspnet-web-api-project/
    Hope this helps you.
    Bhushan | http://www.passionatetechie.blogspot.com | http://twitter.com/BhushanGawale

  • I just got iphone 5c and i am not happy with it. It uses to much data and i don't even know how. I can't get the ringtones i want for my contacts.I got it on my free upgrade but i want to take it back and get something else but where i got it they say i c

    I just got iphone 5c and i am not happy with it. It uses to much data and i don't even know how. I can't get the ringtones i want for my contacts.I got it on my free upgrade but i want to take it back and get something else but where i got it they say i can't because i don't have the earbuds and i have serches or them. now i am suck with a phone i don't like at all until my next upgrade. this is very dishearten

    1. If you are this unhappy with that phone, and the lost earbuds is the only thing stopping you from taking it back, why do not just buy some earbuds. That way you can get rid of that phone. It all depend upon how much you want to get rid of that phone.
    2. Yet if you are stuck with that iPhone, here is something might help you to control the data usage. By design, iPhones do turn off WiFi when they go dormant. So if a download is in progress and so forth when the phone goes dormant, it will switch to use cellular data, if this setting is left on. Therefore, from multi-sources I have learned that if you keep your iPhone connected to a power source, then it will stay connected to the available WiFi.

  • The only thing I did was get down to 5GB HDD space, had a half-import, & something else

    By that I mean here's what I got:
    Both Libraries are the same path....
    As in the title, I was/am running out of HDD drive space, I recently (and last time) had my last iPhone (IOS 7.*.*) iPhoto import go snafu (for first time between this MBP and 3 other iphones....ever), and I think I did something else like at the least a CHECKSUM or VERIFIED or REPAIRED permissions which seemed to make some other stuff squirlley.
    Anyway, I have a mid-late 2010 (OCT) 7,1 MacBook Pro 2.4 GHz Intel Core 2 Duo running Mac OS X Version 10.7.5 with 8 GM 1067 MHz DDR3 RAM and a 250GB 2.5" startup disk
    *******I have a 1TB SSD/HDD here waiting to replace my boot drive, with the adapter kit from OWC and all, but want to back up all my stuf and make it reduntant a few times first.  Problem is I have 1000 great photos since our snowfall here in the NE and don't to lose them and the ones of my daughter and baby daughter. 
    Any help is much appreciated.
    Best Regards,
    GJ

    Sorry but I do not even know what your question is
    as a side note you must always have a minimum of 10GB of free space on your hard drive and more is better
    If your photos are on your iphone then backup to iCloud in case of issues
    I you could post a simple question with only the revelant context it would be good
    LN

  • Black macbook: not sure if its the fan, or something else (noise)

    I got this macbook is september. I had no issues with it, when suddenly it began making noises. Now, I'm a gadget-blog reader, so I've been aware of Macbooks making the "moooo" sound from the fan; however, I'm not sure if my noise is the fan or something else. I get more of a "whrrrrrrrrrrrrrrrr" noise.
    1) I have the macbook plugged in
    2) I leave it on all the time
    3) It began to hear the "whrrrrrrrrrrrrrrrrr" when:
    a) activate visualizer in iTUNES
    b) download shows off iTUNES
    c) have a bunch of windows open and the 512MB Memory is struggling to access each window, if I say, I want to close them.
    Considering this is the uncrashable, flexible, awesome OSX, and should be pesk-free, like say WINXP...I would expect such problems to not exist on the glossy OSX.
    I'm currently studying abroad in the United Kingdom. I bought this macbook in San Francisco just before I left. I have plenty of warranty left. Is this a big issue? It annoys the **** out of me. None of the macbooks demoed in the store had this problem. So in a way, this is false advertising, since I'm reading that a lot of people have this noise issue.
    I've fully updated my firmwares with software updater, but I still get the noise. So I'm at situation that needs some outside help as to what I should do.
    Thanks.

    hard to say if it is serious or not. have you tried resetting the pmu? http://docs.info.apple.com/article.html?artnum=303319 that could very well help the matter.

  • I bought an Apple TV but my HDTV has only one HDMI outlet.  What do I need to operate the Apple TV and my Uverse wireless network. I bought a four outlet hub at Best Buy but I can't't figure it out. Do I need something else?

    I bought an apple TV but my TV has only oine HDMI outlet, so I have to unplug it when I want to watch regular TV. I bought a four plug hub at Bestbuy but can't get it to work.
    Is there something else I can use?

    hdmi spillers and switches are hit or miss some work some don't

  • How can I do mirroring of a screen from new iPad to hdtv using apple tv and still work on something else in my ipad

    How can I do mirroring of a screen from new iPad to hdtv using apple tv and still work on something else in my ipad

    You don't. Mirroring is duplicating your ipad screen on another projector - so you can't have another app going on your iPad without it also showing up on the projected image. Some apps are designed so that you see a different image in the iPad than the mirrored out display, but even then you're within the app itself.

  • HT5922 Can I airplay a movie from safari on my MacBook to Apple TV and still use the computer for something else at the same time?

    Can I airplay a movie from safari on my MacBook to Apple TV and still use the computer for something else at the same time?

    Hi frogjt,
    Welcome to the Apple Support Communities!
    Great question! You can absolutely do this in OS X 10.9. The attached article explains how the process of using AirPlay with Apple TV to create a second display. Also, towards the bottom of the article there are instructions on how to set your Displays preferences on the computer to make sure the TV and MacBook Pro displays are set up the way you want them to be.
    OS X: Using multiple displays in Mavericks
    http://support.apple.com/kb/HT5891
    Have a great day,
    Joe

  • I want to switch my user id with my rescue email address, how can i change my rescue email address to something else to free that up?

    i want to switch my user id with my rescue email address, how can i change my rescue email address to something else to free that up?

    Hi EllaBella0902,
    Welcome to the Support Communities!
    The information below may be able to answer your questions about how to change your rescue email address:
    Manage your Apple ID primary, rescue, alternate, and notification email addresses
    http://support.apple.com/kb/HT5620?viewlocale=en_US
    Before you make any changes, you may want to review the information in the Frequently Asked Questions section of this article:
    Using your Apple ID for Apple services
    http://support.apple.com/kb/HT4895
    This article explains how to update the information in the various services that use the Apple ID if you change it:
    Apple ID: What to do after you change your Apple ID
    http://support.apple.com/kb/HT5796?viewlocale=en_US&locale=en_US
    Cheers,
    - Judy

  • How can I change the BlackBerry Link Network Drive mapping from Z: to something else?

    Hello,
    I generally have a mapping to my NFS server on Z:, and my iTunes library has a relative path to Z: for all of my music - the fact that Link is automatically picking Z: as my network sync target for my device does not work for me to sync music, or anything really. I can't figure out how to change this value to something else.
    I found the registry key: \HKEY_CURRENT_USER\Software\Research In Motion\Device Manager\Device Settings\<DEVICENAME>\VolumeMapping with a default blank REG_SZ - can I use this key at all to manually change drive mappings for my device? If so, what is the key/value pair I need and will this mess up any assumptions taken inside the Link software for synching?
    ... Also, I have a Feature Enhancement Request to go along with this issue: Add a "Change drive map letter" button beside the "Turn on wireless connections to my computer" button in Link, and add the same option in the context menu to the 'Device Manager' for the mapping (which currently just says 'Explore').
    Thanks for the help,
     - Jeff

    I do not know a lot about this subject but since Device Manager is not a Device and the BlackBerry Phone is not recognized as a Device in Disk management unless Mass Storage is turned ON it looks as if by design you cannot change the Drive Letter.
    Also if Mass Storage is turned On in the Phone Settings File Manager and BB link will not work but the BB Phone will then be recognized as a Device in Disk Management and the Drive Letter can be changed, this has no effect on the Drive Letters for Device Manager.
    Normally to change the Drive Letter and Paths of a Device once the Device is plugged you would go to Administrative Tools, Computer Management, Disk Management, right click the Device and choose "Change Drive Letter and Paths"
    Changing the Registry or Uninstalling Device Manager but keeping BB Link or looking for a Utility that can change the Drive Letter such as the one that many XP users had called TweakUI (only worked in XP) or changing the Drive Letter for your Network may be the only way.

Maybe you are looking for

  • Internet on solaris 10

    Ii solaris 10 everything was ok with the instalation. The update manager is working and download-INSTALL some updates. But the web browser can not connect even to sun.com. I know a few things about the network because i was a windows os user.

  • Non-US keyboard users please read, thanks.

    For the last few years I've been using a Swiss French keyboard with FCE. Certain keyboard shortcuts have simply not worked like Shift-Z for "Fit the sequence to the window". There are others. Now I'd like to take advantage of as many keyboard shortcu

  • Address Book flipped last and first names and won't flip back

    Has anyone encountered where after syncing Address Book with Exchange, the first and last names have been flipped and cannot be flipped back? No matter what I do in my Preferences, I can't seem to stop having the address card show the last name first

  • Table for alert messages

    Hi All, Is there any table in SAP that stores message ids for which alerts are thrown. My requiremenst is to extract messages for which alerts are thrown. I found ALXMBALERT , but this does not have any entries. Thanks --Pradeep Edited by: pradeep ne

  • RVS4000 L2TP IPSec

    Currently trying to establish L2TP IPSec VPN tunnels between Windows XP remote client and Windows 2003 RRAS Server. Both the XP remote client and the W2003 RRAS Server are behind RVS4000 routers. Have established that the W2003 RRAS server will accep