WPF XAML designer showing bound property names instead of property values

后端 未结 4 1462
我寻月下人不归
我寻月下人不归 2021-01-06 06:31

One of my XAML files shows a strange behaviour in the XAML designer (but not during runtime):

public class MyDesignTimeViewModel
{

    public MyDesignTimeVi         


        
相关标签:
4条回答
  • 2021-01-06 07:26

    To echo J.G.'s answer, the fix was to enable project code in the XAML designer which had mysteriously been disabled at some point.

    New account so I can't vote or comment, I just didn't like seeing a correct answer downvoted.

    0 讨论(0)
  • 2021-01-06 07:28

    I ran into this issue but the cause was actually that I didn't have the Enable Project Code in XAML Designer enabled.

    0 讨论(0)
  • 2021-01-06 07:29

    Turns out the missing thing was the IsDesignTimeCreatable attribute:

    d:DataContext="{d:DesignInstance vm:MyDesignTimeViewModel, IsDesignTimeCreatable=true}"
    

    With that attribute, everything works as expected.

    0 讨论(0)
  • 2021-01-06 07:35

    Thankyou for the last two answers. In my case 'Enable Project Code in XAML' has randomly turned off as well! I didnt have the designer pulling the view model code for a few weeks. So very happy this has been fixed. So in all to get this working you need:

    d:DataContext="{d:DesignInstance vm:MyDesignTimeViewModel}"

    and the little icon with a blue square and caption 'Enable Project Code in XAML' to be turned on!

    0 讨论(0)
提交回复
热议问题