Page 1 of 1

Binding from a few view models

Posted: 08 Jul 2024, 14:22
by leonid_golovko
I have two view models and the second one is not seen by the system.
How to make the xaml see this second view model?
The second view model called CircleViewModel.
Thank you for the answer in advance!

<Image Source="{StaticResource CenterCircleButtonOff}" Stretch="Uniform" Visibility="{Binding CircleCenterOffMouseVisibility, Converter={StaticResource BooleanToVisibilityConverter}}"/>

[NOESIS/E] Binding failed: Path=CircleCenterOffMouseVisibility, Source=DataModelApp.ViewModel(''), Target=Image(''), TargetProperty=UIElement.Visibility

Re: Binding from a few view models

Posted: 08 Jul 2024, 18:30
by sfernandez
If you manually set the Visibility of the Image to "Visible", does it show as expected?
In that case, are you sure that the viewmodel is available to that Image? If you bind the property CircleCenterOffMouseVisibility to a TextBlock.Text for example, does it show the correct value?

Re: Binding from a few view models

Posted: 09 Jul 2024, 07:18
by leonid_golovko
I just wanted to print the same class 4 times in a diagonal and it print four circles but not in the right coordinates.
It did not change no matter what I did.

Re: Binding from a few view models

Posted: 09 Jul 2024, 12:57
by sfernandez
Could this be related to your other post: viewtopic.php?p=17268#p17268
As I pointed out there, each item in an ItemsControl is wrapped by a ContentPresenter, so canvas position must be set in that element, not in the root of the ItemTemplate.

Re: Binding from a few view models

Posted: 11 Jul 2024, 11:33
by leonid_golovko
Yes. Now this problem was solved! Thank you!