DocumentViewer convention missing #368

Closed
tafehe opened this Issue Sep 9, 2016 · 1 comment

Projects

None yet

2 participants

@tafehe
tafehe commented Sep 9, 2016

ConventionManager static initialization for DocumentViewer element convention is missing.
For default, code below dosn't work:

View:

<UserControl x:Class="XXXX"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:X"
        mc:Ignorable="d">
    <Grid>
        <DocumentViewer x:Name="Viewer" VerticalAlignment="Top" HorizontalAlignment="Left"/>
    </Grid>
</UserControl>

Model:

public class ReportViewModel : Screen
    {
        public IDocumentPaginatorSource Viewer { get; set; }

        public ReportViewModel(XpsDocument document)
        {
            if (document != null)
                Viewer = document?.GetFixedDocumentSequence();
        }
    }

Simple modification in the Bootstrapper:

        protected override void OnStartup(object sender, StartupEventArgs e)
        {
            // Missing convention for DocumentViewr.
            ConventionManager.AddElementConvention<DocumentViewer>(DocumentViewer.DocumentProperty, "DataContext", "Loaded");
            DisplayRootViewFor<MainViewModel>();
        }

does the thing.
Regards.

@nigel-sampson
Contributor

Happy to take a PR adding this convention in.

@nigel-sampson nigel-sampson added this to the v3.1.0 milestone Sep 15, 2016
@nigel-sampson nigel-sampson modified the milestone: v3.0.2, v3.1.0 Nov 14, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment