Frage

I'm having some issues databinding viewmodels in caliburn micro, i have the follwoing code:

<ContentControl Content="{Binding PaymentDetails}">
                <ContentControl.Template>
                    <ControlTemplate TargetType="ContentControl">
                        <Grid>
                            <Controls:RoundedBox/>
                            <ContentPresenter Content="{Binding PaymentDetails}" Margin="10,0,10,0"/>
                        </Grid>
                    </ControlTemplate>
                </ContentControl.Template>
            </ContentControl>

The problem is, that PaymentDetails is a viewmodel, and while databinding to a simple ContentControl works using caliburn micros naming convention to find the view, when using the template, and contentpresenter, the viewmodel binding simply displays the string representation of the viewmodel, rather than finding the view. I'm not an expert in this kind of thing, and i've failed to find the answer on google.

What i want is while using the template, to have the viewmodel binding automatically find the view like usual, but i think i'm missing some understanding here.

War es hilfreich?

Lösung

Instead of Binding to the Content property, use cal:View.Model="{Binding ViewModelName}" instead.

Example:

<ContentControl cal:View.Model="{Binding PaymentDetails}" />
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top