WPF Visibility binding seems that is not setting style
Hi, i have a vertical navigation bar which my <Border> tag is binded to "IsNavBarVisible":
Inside of the Border i have a Grid with the width, background color defined and all the definitions of buttons, icons and their references to static resource design
When my MainViewModel loads I set the property to false because the LoginViewModel appears:
Then, when I run the LoginCommand in my LoginViewModel i set the property to "Visible":
But the problems it's that i just only get a white bar with width property but not the styles applied in my resource dictionary, any help?
8 Replies
This is how it's supposed to be, i get this by changing the property of IsNavBarVisible to "Visible" in MainViewModel constructor
You do call
OnPropertyChanged
in the property setter, right?Yes
I'm not sure why it behaves like that, but you could remove the navbar from the main view and create a separate view that would include the navbar. In that second view host you could host the views that are visible when the user is logged in. That way, when the user is on the login view, they don't see the navbar. When they log in, it shows up and stays there, so you don't have to show/hide it manually
Yeah it's weird, i don't get it after hours trying to fix it
I dont think the property can be of type string, it should be of a correct type, which is Visibility in this case
or you can use binding converter
string property is working, when i hardcode "Visible" in my MainViewModel conustructor the navbar appears
Here is the snippet and also the resulkt
oh, my bad for not reading your question/problem properly 😄 sry