.net - WPF: FixedDocument in Visual Studio 2008 Designer -
is that Visual Studio shows an error when you try to create a fixed document
in XAML For example, the following snippet
& lt; Document View & gt; & Lt; FixedDocument & gt; & Lt; PageContent & gt; & Lt; Fixed page width = "21.0cm" height = "29.7cm" & gt; & Lt; TextBlock & gt; Hello World! & Lt; / TextBlock & gt; & Lt; / FixedPage & gt; & Lt; / PageContent & gt; & Lt; / FixedDocument & gt; & Lt; / DocumentViewer & gt;
compiles and runs perfectly fine, but Visual Studio error displays an error in the list ( property 'Page' type does not support the values of 'PageContent'. < / Code>) It's quite annoying.
I am looking for a solution that allows me to create my documents in an XAML file in Visual Studio without that error message, I have found an alternate solution, which I have an answer below I want to share, but I'm curious if there is a better (more beautiful) solution. "Post-text" itemprop = "text">
I know that the answer has already been given, but I think this answer is good because you do not need to add document veeve.
One way of referencing resources with key names and keeping them in a fixed document with XML, please tell me I do not want to find a way to do this, but it may be possible that this is possible.
Use:
var doc = System.Windows.Application.LoadComponent (new URI ("/ fixed documentexample. Xml ", Uricund. Relativ)) as a fixed document; Doc.AddPages ();
Extension method:
Using the system. Selection; Using System.Windows.Documents; Public Static Class Fixed Document Accented {Public Static Zero Adpex (This Fixed Document Fixed Document) {var Enumerator = Fixed Document. Resource. Gate amenometer (); While (counter. Headbook ()) {var page content = ((enterer entry) present). Price as PageContent; If (page! = Null) {fixedDocument.Pages.Add (pageContent); }}}}
XAM:
& lt; Fixed document xmlns = "http://schemas.microsoft.com/comfx / 2006 / xaml / presentation" xmlns: x = "http://schemas.microsoft.com/winfx/2006/xaml" & gt; & Lt; FixedDocument.Resources & gt; & Lt; PageContent x: key = "page 1" & gt; & Lt; Fixed page width = "793.76" height = "1122.56" & gt; & Lt; Text Block Margin = "50" Text = "Page 1" /> & Lt; / FixedPage & gt; & Lt; / PageContent & gt; & Lt; PageContent x: Key = "page2" & gt; & Lt; Fixed page width = "793.76" height = "1122.56" & gt; & Lt; Text Block Margin = "50" Text = "Page2" /> & Lt; / FixedPage & gt; & Lt; / PageContent & gt; & Lt; /FixedDocument.Resources> & Lt; / FixedDocument & gt;
Comments
Post a Comment