I am trying to bind two properties from different classes in DataTemplate.
<DataTemplate x:Key="DemoItemTemplate" x:DataType="local:DemoInfo">
<NavigationViewItem Visibility="{Binding Visibility, Mode=TwoWay}" Content="{x:Bind Name}"/>
</DataTemplate>
DataType set as DemoInfo for this DataTemplate and Name value updated from DemoInfo.
I have tried view model as source and relative source binding. But Visibility property binding not working from ViewModel class. Any suggest how to achieve this?
Visibility="{Binding Visibility, Source={StaticResource viewModel}}"
I could be wrong, but I thought the
Visibilityproperty had a dedicated enum that contains all the possible options (Visibility Enum) for theVisibilityproperty. So, your binding might be working just fine, but theTypeof the bound property would need to be of typeVisibilityusingSystem.Windows.On a side note, I wouldn't put a visibility property in the view model anyway. I think a more standard approach would be to have a visibility
DependencyPropertyin the immediate code behind of the view for your binding.