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

Top 5 Contributors of the Month
Post New Web Links

View Flowdocument XAML at runtime

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

Hi, I have a richtextbox with an embedded flow document such as:

    <RichTextBox Name="richTextBox1">
      <FlowDocument x:Name="fdMain">
        <Paragraph>Paragraph Text</Paragraph>
At runtime I am programatically adding new paragraphs, and formatting text etc. Is there a way I can display the xaml of the richtextbox (and, hence, flowdocument) as it is updated at runtime?



View Complete Post

More Related Resource Links

How to load a usercontrol xaml at runtime ???????

Hi, I have a usercontrol xaml created in Expression Blend. Similarly i have xaml for other usercontrols as well. Now i want to draw these controls at runtime on click of buttons, the way it works in VS IDE (Toolbox and Drawing area) Is there any way to load such usercontrols on Canvas at runtime ? What would be the best way to load controls at runtime ?      Programmer

VS 2010 XAML Design View Load always fail with a Type Load Exception

Create a new WPF project in VS and change nothing. The Design View will fail to load with the error below. Error    1    Could not load type 'Microsoft.Expression.DesignModel.Core.ISharedInstanceBuilder' from assembly 'Microsoft.Expression.DesignModel, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. Microsoft.Expression.DesignModel is an assembly from Expression Blend. I ever installed Blend 4 RC and uninstall and install Blend 4. I Reflector the assembly I have under Blend 4 bin folder. And cannot find a interface named ISharedInstanceBuilder. But the WPF project is a Template project without any changes. How it get related with Blend 4? And how to fix it? Thanks.  

How to Read values from the XAML file at Runtime

Hi , I am creating a BuildDefinition from code and Loading the Build Process template. Now,I want to read and Validate the Build Process template parameter values.When I am debuggig,I could see that these are in Xaml format. Ex: I have some value "BuildType" as "Daily" in xaml file.I want to read these values and validate them I dont know what is the bestway to read the values.Can any one please let me know how can we do it. Thanks, Srikrishna              

To Pass date in view at runtime!! Can anyone help Very Urgent

Hey I have to pass the Bussiness date in my query at run time I have tried the query below but not able to Execute it. Select * from table name where and RT.BUSINESS_DATE = ? --if only one date --if between two dates and RT.BUSINESS_DATE Between ? and ? Can Any one help me with the Syntax. Will be greatfull!!!

Textrange.Load not loading Xaml code into a FlowDocument


I'm trying to convert text with Xaml tags into a FlowDocument.  I've done this before and it worked fine (as far as I can recall - that was about a year ago.)  Now I can't get this to work:

private Span FormatString(String _textToFormat)
    FlowDocument _formattedDocument;
    Span _formattedText;

    _myString = "<FlowDocument xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\"><Paragraph>This is some <Run FontWeight=\"bold\">bold</Run> text.</Paragraph></FlowDocument>";

    _formattedDocument = new FlowDocument();
    _formattedText = new Span();

    TextRange textRange = new TextRange(_formattedDocument.ContentStart, _formattedDocument.ContentEnd);

    MemoryStream msDocument = new MemoryStream((new ASCIIEncoding()).GetBytes(_myString));
    if (textRange.CanLoad(DataFormats.Xaml))
        textRange.Load(msDocument, DataFormats.Xaml);

// rest of function trimmed - the problem is above

Things work fine up to and including the creation of the MemoryStream (inspection with the debugger shows that the bytes are in there.)  "textRange.CanLoad" also resolves to true, but textRange.Load(msDocument, DataFormats.Xaml) doesn't seem to do anything - after that, a look at "textRa

How read flowdocument xaml to make available in vb code


I'm very very new to WPF and not particularly experienced in VB.Net (mostly a VBA man) so forgive me if this comes across as completely idiotic, cause it more than likely is :-( .....

The problem I have is that I want the user to have the ability to insert buttons into a richtextbox and be able to put essentially as many buttons as they like in and amongst some text.... simple enough....

Problem is I'm finding this impossible with my limitted knowledge of anything WPF related.....

I can use the following code to allow the user to double click in the rtb at a certain point and the code will go off and create a flowdocument (in vb) with an inline container with a button in it and then merge the text from the rtb with the flowdocument.... 



 Dim WithEvents aButton As TextBox = New TextBox (class level variable)

Dim aFlowDocument As FlowDocument = New FlowDocument

Dim bparagraph As Paragraph = New Paragraph

        bparagraph.Inlines.Add(New InlineUIContainer(aButton))




Designer does not remember my settings, for ex., I want to always load xaml into xaml (code) view, n


I am using VS 2010 Ultimate.  It is not remembering my setup when opening .xaml files.  It is very annonying.  I  am pretty sure VS remembers things like that.

I prefer to load my .xaml file to see the code only.  So I usually minimize the design tab.  However, I have to do this every time I open a .xaml file.

I am getting the feeling this setting is stored at the .sln level, which is even more annonying, it should be global setting for all VS sessions.

Any advice?

ASP.NET runtime error in view editor


One day I was developing my MVC app in Visual Studio 2010 and my computer crashed (flaky hardware - now fixed).  But ever since then, in my app, whenever I have a view page or control editor up, the <%@ Page ... %> statement was squigley-underlined in blue with an tool-tip error message like:

/.../page.aspx: ASP.NET runtime error: Could not load file or assembly 'StructureMap, Version=, Culture=neutral, PublicKeyToken=xxxxxxxxxxxx' or one of its dependencies.  The parameter is incorrect. (Exception from HRESULT:0x80070057 E_INVALIDARG))

I deleted and re-added the reference to StructureMap in the References in the solution explorer, deleted and re-copied the actual StructureMap DLL, but the error doesn't go-away.  I deleted the output directories and rebuilt, but still have the problem.

The application still builds and runs okay, but while in the editor, though I continue to have IntelliSense for the HTML stuff, for any C# code inside <% %>'s, the IntelliSense is gone.

If I copy the application tree to another disk or directory, or rename the root directory to a different name, the problem goes away.  But if I use the same name or disk, the problem appears.

Does anyone know how I can fix this?

Maybe it's some corrupted registry entry?

Dynamic columns for View at runtime


I finally got the DynamicLibrary issue nailed down I asked about in another post. The basic gist is that there's a project table that renders to a View. The user can, at runtime, choose the columns to display and the order in which they should be displayed. Here's the method that does the work:

public IQueryable<s_Project> GetFilteredProjects(List<string> columns, string orderBy)
    string sql = string.Empty;

    // First option is that columns were specified and an orderBy was included.
    if(columns.Count > 0 && !string.IsNullOrWhiteSpace(orderBy))
        sql = "select " + columns.SerializeToCsv() + " from s_Projects order by " + orderBy;
    // Second option is that columns were specified by no orderBy was included.
    else if (columns.Count > 0 && string.IsNullOrWhiteSpace(orderBy))
        sql = "select " + columns.SerializeToCsv() + " from s_Projects order by Name";
    // Third option is that no columns were specified but an orderBy was included.
    else if (columns.Count == 0 && !string.IsNullOrWhiteSpace(orderBy))
        sql = "select * from s_Projects order by " + orderBy;
    // Fourth option is that no columns or orderBy was included.
        sql = "select * from s_Projects order by Name";


I declared a datagrid in xaml, now I want to add main columns in this datagrid at runtime through vi


I have declared datagrid in xaml like this ;

<DataGrid AutoGenerateColumns="False" ........


and want to access this datagrid in viewmodel to add columns with headers to this datagrid at runtime. Actually i want to declare any number of columns in grid which i read from database table at execution time. If anybody could help me in this regard....

Cannot View Xaml Files in VS2010 Professionl


I cannot view xaml in vs2010. The files are there, I can build and run.  But I cannot view xaml or designer.

I previously used vs2008 with blend2, and then vs2010 express and blend4 beta.  When I bought and installed vs2010 professional and expression suite 4  my problems began.

I uninstalled all beta and express products before installing.  May I have missed something?

Unable to view the XAML Designer -



I really hope someone knows the answer to this.

I am currently unable to view any XAML/Designer windows in my VS2010 Ultimate. (64bit)

Steps to reproduce (well at least on my install)

1- Create New WPF Project/Solution

2- Double Click on the default MainWindow.xaml

3- Nothing happens!

I've been trying to figure this out for a few days and I am stumped.

I have uninstalled VS2010 and then reinstalled -

installed SP1 - tried the repair .NET 4 etc . . .

Any help on this would be very appreciated.


Truly Understanding View State

This article provides a detailed understanding of the ViewState.

GridView Parent Child View with JQuery Effects

I was just checked how to add some more cool effects to the GridView control using JQuery. In this post I will display parent-child data in the GridView control with some help of the wonderful JQuery library.

Let's first populate the GridView control.

Model View Controller (MVC) for ASP.NET

Model View Controller (MVC) architectures, immediately wonder how the MVC pattern can be applied in an ASP.NET world. This article will demonstrate how the MVC pattern can be applied to an ASP.NET web application and still maintain the basic Microsoft supplied architecture.

Create And Run Excel Macro At Runtime in C#

You've been tasked with writing a Windows Form application using the .NET Framework that interacts with Microsoft Excel. If you are new to working with Excel in .NET and are having trouble learning how to format certain cells or cell ranges, then this little tip will come in handy. Rather than scour the internet hoping to find the correct set of constants or method syntax for formatting your spreadsheet, use the built in tools in Excel to write the familiar VBA code for you. Then, you can paste the VBA code generated by Excel into the sample C# code below and run it dynamically at runtime.

jQuery grid view plugin

jqGridView is new, client-rich, XML-based, ajax grid plugin for jQuery library. jqGridView provides professional solution for representing and editing tabular data on the web. Carefully designed, with powerful script API, this editable DHTML grid is easy configurable with XML, and shows convincing results working with large amounts of data. jqGridView allows easy implementation of nice looking(managed through css). jqGridView is not platform-depending plug-in, it can be used with different web -programming platforms like: ASP .NET/ASP, PHP, JAVA, CGI scripts etc. jqGridView has hight bowser compatibility.
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