DesignTime support bindings getting weird
See original GitHub issueI have an application that is split up in several libraries (containing views and models). However, the execution of the application is ok. This is the simple test result:
This shows a Container that has a property containing another Screen that needs to be resolved at runtime.
I have added two DesignTime ViewModels (one for Child and one for Container).
public class DesignContainerViewModel : Screen, IContainerViewModel
{
public DesignContainerViewModel()
{
this.Text = "DesignTime Container";
this.Child = new DesignChildViewModel(); // adding another DesignTimeViewModel manually
}
public string Text { get; set; }
public IScreen Child { get; set; }
}
When selecting the ChildView everything seems to work:
When selecting the Container (with the ChildView inside):
The DesignViewModel for the Child can’t be resolved to the corresponding View. Sounds ok, cause there is no existing mapping (have to figure out how to replace “DesignTime” in namespace and “Design” in ViewModel name… however if I change the code above to contain the real model instead of the DesignTimeViewModel:
public class DesignContainerViewModel : Screen, IContainerViewModel
{
public DesignContainerViewModel()
{
this.Text = "DesignTime Container";
this.Child = new ChildViewModel(); // using real model in designtimeviewmodel now
}
public string Text { get; set; }
public IScreen Child { get; set; }
}
… it looks like this:
nice… BUT WAIT… there is something wrong. There is written “DesignTime Container” in both labels but there should be “DesignTime Child” in the lower one.
public class DesignChildViewModel : Screen, IChildViewModel
{
private readonly string text;
public DesignChildViewModel()
{
this.text = "DesignTime Child"; // not shown!?
}
public string Text
{
get
{
return this.text;
}
}
}
I use VS 2013 and WPF for this. This is the sample to reproduce this behavior. CaliburnMicroDesignTimeSupport.zip
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:11 (2 by maintainers)
Top GitHub Comments
I think I’ve run into (essentially) this same issue. I have created a really basic reproducer here: https://github.com/eogas/CaliburnMicroDesignTimeNestedBindingBug
Basically it’s just a root window that contains a child view, which itself contains another child view. It takes a bit of building to get the XAML window to render everything, but once it’s stable, this is what I see.
ChildItemView
ItemView
ShellView
ItemView is able to render ChildItemView correctly as far as the hardcoded portions are concerned, however it doesn’t render the bindings to ChildItemViewModel. Similarly, in ShellView, we can see the hardcoded portions of ItemView, but its bindings, including the ChildItemView, are not resolved at design time.
But everything works fine at runtime:
@superware has created #388 to discuss it, feel free to add your ideas.