AutoHide Progressbar with StyleTriggers

I would like to hide a progressbar in WPF using databinding. Whenever a property is 0, the progressbar should hide: I try the following code

(Info: My current datacontext is a class that holds an integer property 'CurrentIndex')

<ProgressBar Minimum="0" Maximum="100" Value="{Binding CurrentIndex, UpdateSourceTrigger=PropertyChanged}" Visibility="Visible">
    <ProgressBar.Style>
        <Style TargetType="{x:Type ProgressBar}">
            <Style.Triggers>
                <DataTrigger Binding="{Binding CurrentIndex}" Value="0">
                    <Setter Property="Visibility" Value="Hidden"/>
                </DataTrigger>
            </Style.Triggers>
        </Style>
    </ProgressBar.Style>
</ProgressBar>

What is wrong with this code? Why does the progressbar still show up when the CurrentIndex is 0? (in the model behind, the value of 'CurrentIndex' is 0 by default, when the control is loaded)

Answers


DP precedence, do not set Visibility on the control itself (local value > style).


Need Your Help

Daily rollover for a FileOutputStream using Protocol Buffers?

java log4j protocol-buffers fileoutputstream

I am getting a stream of data from a server (in binary format). This data is serialised using Google protocol buffers. I'm attempting to do a daily rollover (i.e. if next day occurs write to new file

IE positions left sidebar below content

html css positioning

I am not familiar with this website but I am desperately seeking help with the website I am building. I'm sorry if I'm not in the right place or asking my question incorrectly, so please tell me if...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.