mvvm - WPF Showing / Hiding a control with triggers -


i'm new wpf , trying create xaml logic show / hide control based on value of allowmisctitle on viewmodel. xaml consist of 2 fields combobox of standard tiles ("mr", "mrs", ..., "other") when "other" selected want textbox display.

i've created follow xaml:

                <dockpanel validation.error="validation_error" horizontalalignment="stretch">                 <combobox itemssource="{binding path=titles, mode=onetime}"                        text="{binding path=title}"/>                 <textbox x:name="txtbxtitle" margin="5,5" visibility="visible">                     <textbox.style>                         <style>                             <style.triggers>                                 <datatrigger binding="{binding path=allowmisctitle}" value="false">                                     <setter property="textbox.visibility" value="hidden"/>                                 </datatrigger>                             </style.triggers>                         </style>                     </textbox.style>                 </textbox>              </dockpanel> 

that trigger won't work because have set visibility property explicitly in textbox

do this:

<textbox x:name="txtbxtitle" margin="5,5">     <textbox.style>         <style>             <style.triggers>                 <datatrigger binding="{binding path=allowmisctitle}" value="false">                       <setter property="textbox.visibility" value="hidden"/>                 </datatrigger>             </style.triggers>         </style>     </textbox.style> </textbox> 

the reason dependency property value precedence.


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -