Home > Net >  Changing property IsIndeterminate on MaterialDesign button in WPF
Changing property IsIndeterminate on MaterialDesign button in WPF

Time:06-25

I'm using a material design button in WPF and I'm not quite sure how to control the property IsIndeterminate from within C# code as the below does not work, like it usually does with "standard" properties like Content etc.

BTN_Search.materialDesign:ButtonProgressAssist.IsIndeterminate = true;

The WPF for the button below:

<Grid Width="124" Margin="5" VerticalAlignment="Center">
            <Button Style="{StaticResource MaterialDesignRaisedButton}"
                    materialDesign:ButtonProgressAssist.Value="-1"
                    materialDesign:ButtonProgressAssist.IsIndicatorVisible="True"
                    materialDesign:ButtonProgressAssist.IsIndeterminate="False"
                    Content="Search"
                    Margin="2,0"
                    IsEnabled="{Binding DataContext.ControlsEnabled, RelativeSource={RelativeSource FindAncestor, AncestorType=Window}}" 
                    x:Name="BTN_Search"
                    Click="Search_Click"/>
        </Grid>

I want the materialDesign:ButtonProgressAssist.IsIndeterminate property to be changed in the Click event when the button is pressed and then once I am done processing I need to change it back to False.

CodePudding user response:

It is a dependency property so it can be set like this:

ButtonProgressAssist.SetIsIndeterminate(BTN_Search, true);

There is other examples on Github in the MaterialDesignInXamlTooking project https://github.com/MaterialDesignInXAML/MaterialDesignInXamlToolkit/blob/master/MaterialDesignThemes.Wpf.Tests/ButtonProgressAssistTests.cs

  • Related