xaml - WPF Changing the style of a UserControl in a ListView -


i'm having issues setting style of usercontorl. have usercontrol called busyindicator defined in file. below xaml.

<usercontrol x:class="foo.client.ui.svgs.busyindicator"              xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"              xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"              xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"               xmlns:d="http://schemas.microsoft.com/expression/blend/2008"               mc:ignorable="d"               d:designheight="300" d:designwidth="300"              datacontext="{binding relativesource={relativesource self}}"              >     <usercontrol.template>         <controltemplate>             <border width="{binding width}" height="{binding height}" visibility="{templatebinding control.visibility}">                 <canvas width="{binding width}" height="{binding height}"  visibility="{templatebinding  control.visibility}">                     <path fill="{binding foreground}"                           height="25"                           width="25"                           data="m20.519,4.617c-3.262-3.111-7.821-3.965-12.03-2.236 c-4.282,1.76-6.895,5.654-6.863,10.227l3.658-0.025c5.263,9.51,7.017,6.892,9.894,5.71c2.81-1.154,5.85-0.598,8.037,1.456 l-1.395,1.376h5.39v3.227l20.519,4.617z"/>                 </canvas>             </border>         </controltemplate>     </usercontrol.template> </usercontrol> 

i reference usercontrol , use in listview. object listview binding has property named status. when status set "running", i'd change style. when run it, button hidden know status property notifying properly. svg:busyindicator control remains unchanged.

<usercontrol x:class="foo.views.screens.collectionresultsview"                  automationproperties.automationid="collectionresultsview"                  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"                  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"                  xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"                    mc:ignorable="d"                  xmlns:d="http://schemas.microsoft.com/expression/blend/2008"                  xmlns:svg="clr-namespace:foo.client.ui.svgs;assembly=foo.client.ui"                   d:designwidth="700">     <listview itemssource="{binding targetstatusview}">         <stackpanel>             <button>                 <textblock text="x"></textblock>                 <button.style>                     <style targettype="button">                         <setter property="visibility" value="visible" />                         <style.triggers>                             <datatrigger binding="{binding status}" value="running">                                 <setter property="visibility"  value="hidden" />                             </datatrigger>                         </style.triggers>                     </style>                 </button.style>             </button>             <svg:busyindicator width="25" height="25">                 <svg:busyindicator.style>                     <style targettype="svg:busyindicator">                         <setter property="visibility" value="visible" />                         <style.triggers>                             <datatrigger binding="{binding status}" value="running">                                 <setter property="visibility" value="hidden"/>                             </datatrigger>                         </style.triggers>                     </style>                 </usercontrol.style>             </svg:busyindicator>         </stackpanel>     </listview> </usercontrol> 

i tried change targettype usercontrol didn't work either.

<svg:busyindicator width="25" height="25">     <usercontrol.style>         <style targettype="usercontrol">             <setter property="visibility" value="visible" />             <style.triggers>                 <datatrigger binding="{binding status}" value="running">                     <setter property="visibility" value="hidden"/>                     <setter property="foreground" value="white" />                 </datatrigger>             </style.triggers>         </style>     </usercontrol.style> </svg:busyindicator> 

setting <svg:busyindicator width="25" height="25" visibility="hidden"> work if add <setter property="visibility" value="hidden" /> style, above <style.triggers>, not work.

i tried other properties opacity , height without success.

what missing?

the issue way defined busyindicator control. because datacontext set {binding relativesource={relativesource self}}. this, when used in listview, context control , not data bound listview. binding="{binding status}" did work because busyindicator usercontrol doesn't have status prooperty.

we updated control below , worked.

<usercontrol x:class="foo.client.ui.svgs.busyindicator"              xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"              xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"              xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"               xmlns:d="http://schemas.microsoft.com/expression/blend/2008"               mc:ignorable="d"               d:designheight="300" d:designwidth="300">     <canvas>                 <path fill="{binding relativesource={relativesource findancestor, ancestortype={x:type usercontrol}}, path=foreground}"                            data="m20.519,4.617c-3.262-3.111-7.821-3.965-12.03-2.236 c-4.282,1.76-6.895,5.654-6.863,10.227l3.658-0.025c5.263,9.51,7.017,6.892,9.894,5.71c2.81-1.154,5.85-0.598,8.037,1.456 l-1.395,1.376h5.39v3.227l20.519,4.617z">                 </path>                 <path fill="{binding relativesource={relativesource findancestor, ancestortype={x:type usercontrol}}, path=foreground}" data="m4.733,20.634c3.26,3.111,7.82,3.964,12.03,2.234c4.281-1.76,6.894-5.652,6.862-10.227l-3.658,0.025c0.021,3.073-1.733,5.69-4.61,6.872c-2.808,1.155-5.85,0.598-8.037-1.457l1.396-1.375h3.324v5.315l4.733,20.634z" >                 </path>     </canvas>        </usercontrol> 

Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -