Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WPA81] Design time binding not working with controls inside DataTemplate #33

Closed
ebussa opened this issue Apr 25, 2014 · 4 comments
Closed
Assignees
Labels
Milestone

Comments

@ebussa
Copy link

ebussa commented Apr 25, 2014

I have a Windows.UI.Xaml.Controls.Page with the following attributes:

xmlns:d="http://schemas.microsoft.com/expression/blend/2008 
xmlns:designData="using:Screens.DesignData"
xmlns:cm="using:Caliburn.Micro"
d:DataContext="{d:DesignInstance Type=designData:ViewModel, IsDesignTimeCreatable=True}"
cm:Bind.AtDesignTime="True"

This Xaml does not properly bind the Items property of the DesignInstance to the ListView.ItemsSource:

<HubSection>
    <DataTemplate>
        <StackPanel cm:Bind.Model="{Binding}">
            <ListView x:Name="Items"/>
        </StackPanel>
    </DataTemplate>
</HubSection>

However, if I change my syntax to this the binding works:

<ListView ItemsSource="{Binding Items}"
@tibel
Copy link
Contributor

tibel commented Apr 25, 2014

Is this a duplicate of #2? Try the tip from @nigel-sampson in the linked issue.

@ebussa
Copy link
Author

ebussa commented Apr 26, 2014

I made the change and am now calling base.Initialize() in the App constructor. On my page, I removed the {Binding Items} code from the ListView and replaced it with x:Name="Items", saved and recompiled. When I switched from Xaml to Design view, I am still not seeing the sample data from my DesignInstance.

If I swap out x:Name="Items" and replace it with {Binding Items}, the sample data renders.

fyi, I'm using CM beta2, Windows 8.1 w/ Universal Project. The page is in the Windows Phone 8.1 project.

@tibel tibel removed the duplicate label Apr 26, 2014
@tibel tibel changed the title Design time binding not working with controls inside DataTemplate [Win81] Design time binding not working with controls inside DataTemplate Apr 26, 2014
@tibel tibel changed the title [Win81] Design time binding not working with controls inside DataTemplate [WPA81] Design time binding not working with controls inside DataTemplate Apr 26, 2014
@tibel tibel added the bug label Apr 26, 2014
@tibel tibel added this to the Version 2.0 milestone Apr 26, 2014
@nigel-sampson
Copy link
Contributor

I suspect this could be an issue more with the Hub and it's use of DataTemplates, will look into it.

@nigel-sampson
Copy link
Contributor

The problem is definitely the data templates and the conventions not being applied. While Bind.Model helps at run time it doesn't help at design time.

<HubSection>
  <DataTemplate>
    <StackPanel caliburn:Bind.Model="{Binding}" caliburn:Bind.AtDesignTime="True">
      <ListView x:Name="Items"/>
    </StackPanel>
  </DataTemplate>
</HubSection>

Should gives me design time inside the data template as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants