setting data context of silverlight user control leaves the control as always visible
I have a 'searchwin.xaml' user control in a Silverlight page called Mainpage.xaml. 'searchwin' has its own viewmodel 'searhwinVM'. I have set searchwin's datacontext to its viewmodel in the Mainpage xaml like this
<UserControl.Resources>
<vm:SearchWin x:Name="SearchWinVM" x:Key="SearchWinVM" /> </UserControl.Resources>
<part:SearchWin ..... {other properties here}
Visibility="{Binding Converter={StaticResource Bool开发者_C百科eanToVisibilityConverter}, Path=IsSearchVisible}"
DataContext="{StaticResource SearchWinVM}"/>
This search control I want to set as invisible by default and visible only when I change to a particular value in my listbox which is on the mainpage.xaml. Setting the datacontext of the UC in the mainpage.xaml or programatically in the mainpage.xaml.cs causes the control to always be visble. I cant get it to hide now. If I remove the datacontext it works well as expected. Any ideas how to fix this?
Thanks for your time...
Have you verified that your converter is being called at all? I'd just put a breakpoint in and see what happens.
精彩评论