Good Morning!
I have a WPF application that will display a number of different file types based on command line args it receives. It works fine, but I want to go back and refactor it. I have only been a developer for a few years and would like to master MVVM.
I am using an MVVM design package called Stylet. In my PDF view I am using a Telerik RadPdfViewer control to which Telerik has all this binding stuff built in for you. For example, I am binding the right click context menu with the commands "select all" and "copy" using their pre configured command bindings.
I would like to bind the "Document Source" property TO MY viewmodel so I can pass in the paths of documents I want to load. However, the DataContext of the control is bound to Telerik's CommandDescriptors preventing the binding to my viewmodel.
<telerik:RadPdfViewer x:Name="radPdfViewer" Grid.Row="1" 
                          DataContext="{Binding CommandDescriptors, ElementName=radPdfViewer}" 
                          DocumentSource="{Binding PDFDoc}" 
                          telerik:RadPdfViewerAttachedComponents.RegisterFindDialog="True" 
                          HorizontalAlignment="Stretch" Margin="0,0,0,0" VerticalAlignment="Stretch" 
                          telerik:StyleManager.Theme="Office_Black" Grid.ColumnSpan="2">
        <telerik:RadContextMenu.ContextMenu>
            <telerik:RadContextMenu>
                <telerik:RadMenuItem Header="Select All" 
                                     Command="{Binding SelectAllCommandDescriptor.Command}" />
                <telerik:RadMenuItem Header="Copy" 
                                     Command="{Binding CopyCommandDescriptor.Command}" />
            </telerik:RadContextMenu>
        </telerik:RadContextMenu.ContextMenu>
    </telerik:RadPdfViewer>
public class PDFViewModel
{
    private string _pdfDoc;
    public string PDFDoc
    {
        get
        {
            return _pdfDoc;
        }
        set
        {
            _pdfDoc = value;
        }
    }
    public PDFViewModel()
    {
        PDFDoc = @"t:\share\large.pdf";
    }
}
I see two choices
- I break Telerik's prebuilt command bindings and figure out how to bring the select all and copy functions to my viewmodel. 
- Stylet has an s:Action function where I can call a method where I can load the document into the RadPdfViewer control using C#. I would need to somehow get control of the gui control in the method of my viewmodel and I am not sure how to do that. 
Is there a better way? A little nudge in the right direction would be greatly appreciated.
 
    