Answered Resource Dictionary and Content control

  • Thursday, September 06, 2012 6:25 AM
     
     

    Hi All

    What is the difference between resource dictionary and content control..

    I want to know if i am creating a xaml using resource dictionary and a presentation model which should link to that xaml...i guess if we are creating xaml using resource dictionary we have to register the presentation model

    But if we are creating xaml using content control..is it needed.

    pls clarify..your help is appreciated

All Replies

  • Thursday, September 06, 2012 7:36 AM
     
     Answered

    No, you dont have to if you are using Content control.

    You just have to write in resource file somethink like this:

    <Window.Resources>

    <DataTemplate DataType="{x:Type vm:MyViewModel}">
                <vw:MyUserControl />
     </DataTemplate>   

    </Window.Resources>

    use it as:

    <ContentControl Content="{Binding ViewModelPath}" /> 

    Regards

    Agrawal

    -------------------------------------------------------------------------

    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".