none
XAML can I use the Source and Content Properties in a Frame Control? RRS feed

  • Question

  • I created a solution to be able to show a Page in a Frame control during Design Time while using the MVVMLight tool kit and a navigation service pointing to the Source and URI Property.  

    However, in order to be able to get the design time experience and runtime page displaying in the frame, I've ended up using both a Content and Source property in the Frame Control.  IS THIS OK?  I've never seen anyone do this before?

    I started with the MvvmLight WPF template program and modified it with a Frame, Pages, and properties.  I have a solution on github.com/floppydisk525/MvvmLight_Frame_DesignTime.   I have some pictures there as well that show a frame with and without the loaded page.  

    First I added the code to the MainWindow.xaml:

    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:ignore="http://www.galasoft.ch/ignore"
    xmlns:v="clr-namespace:MvvmLight_Frame_DesignTime"

    Then modified the Frame Control XAML by adding d: designtime code, including the Content property:

    <Frame HorizontalAlignment="Left" Height="237" Margin="25,120,0,0" VerticalAlignment="Top" Width="243"
        d:DataContext="{d:DesignInstance Type=v:IntroPage, IsDesignTimeCreatable=True}" 
        Content ="{Binding}"                 
        Source="{Binding FrameUri}"/>

    The code works, but I'm wondering if it won't cause me issues down the road as I make a larger program?  


    Sunday, April 1, 2018 10:37 PM

All replies

  • Hi FloppyDisk525,

    >>The code works, but I'm wondering if it won't cause me issues down the road as I make a larger program? 

    Design-time attributes are ignored during compilation and have no effect at run time.

    I can't think of any problems unless you mess up the code.

    Best regards,

    Bob


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, April 2, 2018 8:26 AM
  • Hi FloppyDisk525,

    Is there any update? do you resolve the issue? if the issue still exists, could you please provide a bit more information, such as related code, the steps how to reproduce the issue.

    Best regards,

    Zhanglong


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, April 10, 2018 9:48 AM
  • Zhanglong,

    Thanks for asking.  My question is more or less - is this ok?  I did post my code to https://github.com/floppydisk525/MvvmLight_Frame_DesignTime and have a pretty extensive write up with pictures.  

    It seemed to work, but I am not very good at this and wondered if there was a better way.

    Thanks again,

    Mark

    Wednesday, April 11, 2018 6:17 AM
  • Hi FloppyDisk525,

    Since your issue is more related to MVVMLight, which is a 3rd-party framework, I would suggest that you could post your issue on MVVMLight GitHub for suitable support.

    https://github.com/lbugnion/mvvmlight/issues

    Thanks for your understanding.

    Best regards,

    Zhanglong


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, April 17, 2018 8:40 AM