2
votes

I am trying to load a UserControl inside a wpf popup control, From the code below i can see the Popup opening with yellow background but the ContentControl with View is not getting loaded. I am using Caliburn Micro to resolve View and ViewModel. Below is my xaml, The contentcontrol outside the pop works fine, But the same content control inside Popup displays only the yellow background.

<ContentControl x:Name="SearchListViewModel" />
                <ToggleButton Name="button1">
                    <ToggleButton.Template>
                        <ControlTemplate TargetType="ToggleButton">
                            <TextBlock Text="Select" />
                        </ControlTemplate>
                    </ToggleButton.Template>
                </ToggleButton>
                <Popup IsOpen="{Binding IsChecked, ElementName=button1}" StaysOpen="False">
                    <Border>
                        <StackPanel
                            Width="500"
                            Height="500"
                            Background="Yellow"
                            Orientation="Vertical">
                            <ContentControl x:Name="SearchListViewModel" />
                        </StackPanel>
                    </Border>
                </Popup>
1
Assuming you are using the default view/view model resolution mechanism, then you should rename the content control to SearchList instead of SearchListViewModel. Your view should be called SearchListView. Caliburn assumes that the view model is called the name + ViewModel on the end. - Jack Hughes

1 Answers

1
votes

I know this is somewhat late, but Caliburn Micro won't/can't discover ContentControl inside a Popup control. Thus the content control won't bind to the SearchListViewModel property.

You can, however, specify the correct bind path:

<ContentControl cal:View.Model="{Binding Path=SearchListViewModel,Mode=OneWay}"/>

note: you also need to reference the cal namespace:

xmlns:cal="clr-namespace:Caliburn.Micro;assembly=Caliburn.Micro.Platform"