Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

Binding to FlowDocumentReader Document field help?...

$
0
0

Hi,

OS: Windows 7 SP1
IDE: VS 2010 Express
WPF Project: .NET 4.0
Code Practice: Prism, Unity, MVVM

I've seen posts on the internet regarding the Binding to a FlowDocument, but these post were all dated 2007-8 and all referred to a class name BindableRun. Has this limitation been updated for the .NET 4+ and if so can anyone link me to an example or documentation?

Here my code in what I trying to do and I don't to stray away using the FlowDocumentReader:
The View:

<!-- content --><Grid 
            x:Name="ContentGrid" 
            Grid.Row="1"
            VerticalAlignment="Stretch"><FlowDocumentReader 
                Document="{Binding FlowDocumentText}" 
                x:Name="SpreadsheetDocument" 
                Grid.Row="1" ViewingMode="{Binding Path=ReaderViewingMode}"></FlowDocumentReader></Grid>

The ViewModel:
    public class SpreadsheetDocumentVM : ViewModelBase, ISpreadsheetDocument
    {
        private readonly IUnityContainer container;
        private readonly IRegionManager regionManager;
        private readonly IEventAggregator eventAggregator;
        private IExcelService excelService;public DelegateCommand UpCoreFilePropertiesPart { get; set; }

        public SpreadsheetDocumentVM(IUnityContainer container, IEventAggregator eventAggregator, IRegionManager regionManager)
        {
            this.container = container;
            this.regionManager = regionManager;
            this.eventAggregator = eventAggregator;
            this.excelService = container.Resolve<IExcelService>(ServiceNames.ServiceExcel);this.flowDocumentText = new FlowDocument();
            this.flowDocumentText.FontSize = 16;this.readerViewingMode = FlowDocumentReaderViewingMode.Scroll;UpCoreFilePropertiesPart = new DelegateCommand(OnUpCoreFilePropertiesPart);
       }private void OnUpCoreFilePropertiesPart()
        {
            SpreadsheetDocument document = this.excelService.GetSpreadSheetDocument();

            string runText =
                "This text has some altered typography characteristics.  Note" +"that use of an open type font is necessary for most typographic" +"properties to be effective.";

            //References to the workbook and Shared String Table.
            Workbook workbook = document.WorkbookPart.Workbook;
            Sheets sheets = document.WorkbookPart.Workbook.Sheets;

            // Create paragraph with some text.
            Paragraph parTitle = new Paragraph();
            parTitle.FontSize = 18;
            parTitle.FontWeight = FontWeights.Bold;
            parTitle.Inlines.Add("Spreadsheet Document");

            Paragraph parSub = new Paragraph();
            parSub.FontSize = 12;
            parSub.FontWeight = FontWeights.Thin;
            parSub.Inlines.Add(runText);

            Paragraph parCoreFilePropertiesPart = new Paragraph();
            parCoreFilePropertiesPart.Inlines.Add("Core File Properties Part");
            parCoreFilePropertiesPart.Inlines.Add(new LineBreak());
            parCoreFilePropertiesPart.Inlines.Add("ContentType: " + document.CoreFilePropertiesPart.ContentType);
            parCoreFilePropertiesPart.Inlines.Add(new LineBreak());
            parCoreFilePropertiesPart.Inlines.Add("RelationshipType: " + document.CoreFilePropertiesPart.RelationshipType);
            parCoreFilePropertiesPart.Inlines.Add(new LineBreak());
            parCoreFilePropertiesPart.Inlines.Add("Uri: " + document.CoreFilePropertiesPart.Uri.ToString());
            parCoreFilePropertiesPart.Inlines.Add(new LineBreak());
            parCoreFilePropertiesPart.Inlines.Add("DocumentType: " + document.DocumentType.ToString());

            //Paragraph parData = new Paragraph();
            //foreach (D dpart in document.CoreFilePropertiesPart.DataPartReferenceRelationships)
            //{
            //    parData.Inlines.Add("DataPart: " + dpart.ToString());
            //    parData.Inlines.Add(new LineBreak());
            //}

            flowDocumentText.Blocks.Add(parTitle);
            flowDocumentText.Blocks.Add(parSub);
            flowDocumentText.Blocks.Add(parCoreFilePropertiesPart);
            RaisePropertyChanged(() => FlowDocumentText);
        }private FlowDocument flowDocumentText;
        public FlowDocument FlowDocumentText
        {
            get { return flowDocumentText; }
            set
            {
                flowDocumentText = value;
                RaisePropertyChanged(() => FlowDocumentText);
            }
        }

After the view is loaded I'm using a RibbonButton to load Excel info to the FlowDocument, but it's not updating, when I load the info during initialization is display's, but I need to be able to minipulate the FlowDocument programmically to add more info.

Any help would really be appreciated! Let me know if you need more info. Thanks for your help!.. :)

Code is like a box of chocolates!...


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>