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

Some bindings not working in TabControl #92

Open
stilettk opened this issue Sep 3, 2014 · 4 comments
Open

Some bindings not working in TabControl #92

stilettk opened this issue Sep 3, 2014 · 4 comments
Labels

Comments

@stilettk
Copy link

stilettk commented Sep 3, 2014

Hello!
I've noticed an issue when using Caliburn.Micro to connect Views and ViewModels in TabControl. Some of the ElementName bindings are not working, and what's interesting is that it happens only if there are more than one tab in TabControl.
I have this issue in many places in my application, and I am attaching a sample application with one of this issues: https://drive.google.com/open?id=0B4RWnYweQI-GVUk1SUVGTmxkZ0E

In this sample there are two TabControls: left one is using Caliburn.Micro and the right one is using standard implicit DataTemplates. I've simulated tab's loading, so tab's contents are shown after a slight delay.
Steps to reproduce:

  1. Add one tab with a button
  2. Click header checkbox and notice that it's working in both TabControls.
  3. Add one more tab.
  4. Click header checkbox and notice that checkbox in left TabControl is broken, but is working in the right one. This confirms that it is Caliburn.Micro's issue.

I think that it has something to do with a fact that the tab's View is collapsed during initialization.
Please fix this issue: I want to use Caliburn.Micro's capabilities of wiring Views and ViewModels instead of writing implicit DataTemplates.

@nigel-sampson
Copy link
Contributor

It's certainly an interesting bug, I'm still looking at what the ultimate cause is. It's definitely something around the collapsed nature of the view as removing the Task.Delay or default IsReady to true resolves the issue.

@remcoros
Copy link

remcoros commented Oct 9, 2014

If you enable wpf binding tracing, you will see this error in the debug output window:

System.Windows.Data Error: 4 : Cannot find source for binding with reference 'ElementName=Root'. BindingExpression:Path=DataContext.AllSelected; DataItem=null; target element is 'CheckBox' (Name=''); target property is 'IsChecked' (type 'Nullable`1')

Most likely, because of the collapsed view and WPF visual/logical tree and binding magic.

If you implement the BindingProxy from http://stackoverflow.com/questions/15494226/cannot-find-source-for-binding-with-reference-relativesource-findancestor

and replace ElementName binding with:

IsChecked="{Binding Source={StaticResource proxy}, Path=Data.AllSelected, UpdateSourceTrigger=PropertyChanged}"

it works.

(I just tested it using your example project)

I tried to find the issue within caliburn micro, but I have no clue where to start looking for this.

Anyone else?

@stilettk
Copy link
Author

I've updated the link to sample because it was deleted from the old link.

@stilettk stilettk changed the title ElementName bindings not working in TabControl Some bindings not working in TabControl Mar 26, 2016
@stilettk
Copy link
Author

I've edited the title because the issue is not in ElementName bindings: I have changed the source of a binding to RelativeSource={RelativeSource FindAncestor, AncestorType=UserControl} and the problem is still there.

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