Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
325
Change center text size when using XamBusyIndicator's ProgressRing
posted

<Canvas Grid.Column="10">
    <ig:XamBusyIndicator Canvas.Left="0"
                         Canvas.Top="-20"
                         Margin="0"
                         Animation="ProgressRing"
                         IsBusy="True"
                         IsIndeterminate="False"
                         ProgressValue="1">

        <ig:XamBusyIndicator.Resources>
            <Style x:Key="BusyAnimationsStyle" TargetType="igPrim:BusyAnimationPresenter">
                <Setter Property="Height" Value="60" />
                <Setter Property="Width" Value="60" />
            </Style>

            <Style BasedOn="{StaticResource BusyAnimationsStyle}" TargetType="igPrim:ProgressRingBusyAnimationPresenter">
                <Setter Property="Background" Value="Transparent" />
                <Setter Property="Foreground" Value="Black" />
            </Style>

        </ig:XamBusyIndicator.Resources>

        <ig:XamBusyIndicator.OverlayStyle>
            <Style TargetType="{x:Type Rectangle}">
                <Setter Property="Opacity" Value="1" />
                <Setter Property="Fill" Value="Transparent" />
            </Style>
        </ig:XamBusyIndicator.OverlayStyle>



    </ig:XamBusyIndicator>
</Canvas>

I want to change the size of the center text, but I don't know how. Foreground and FontStyle properties are applied. However, the resize property does not apply.

  • 2680
    Verified Answer
    Offline posted

    Hello,

    Thank you for providing sample code-snippet!

    I have been looking into it and what I can say is that it appears the TextBlock inside the ProgressRing indicator type is not directly exposed for styling. It is part of the ProgressRingBusyAnimationPresenter’s element Template. The presenter you have already attempted to style by assigning the Background and Foreground properties, however, in order to set the size, the Template itself has to be modified.

    The latter can be found in the default style files under

    C:\Program Files (x86)\Infragistics\*your-version*\WPF\DefaultStyles\Windows\PrimitivesGeneric.xaml ,

    from lines 3134 up to 3297.

    My suggestion is to add a separate ResourceDictionary file containting the ControlTemplate in order not to clutter the XAML file. The ControlTemplate has to be assigned a custom Key. In it, the TextBlock’s font size and other properties can be altered. Then the newly created Resource dictionary has to be added to the MergedDictionaries collection of the XamBusyIndicator’s Resources, following your already defined styles setup:

    <ig:XamBusyIndicator.Resources>
         <ResourceDictionary>
             <ResourceDictionary.MergedDictionaries>
                 <ResourceDictionary Source="PRBAP_IsNotIndeterminateRoot_Template.xaml" />
             </ResourceDictionary.MergedDictionaries>
    <!—Other Styles -->
        </ResourceDictionary>
    </ig:XamBusyIndicator.Resources>

    What is left is to assign the so created ControlTemplate to Template Setter Value of the Style targeting the igPrim:ProgressRingBusyAnimationPresenter:

                            <Style BasedOn="{StaticResource BusyAnimationsStyle}"
                                   TargetType="igPrim:ProgressRingBusyAnimationPresenter">
                                <!—Other Setters -->
                                <Setter Property="Template" Value="{StaticResource CustomTemplate}"></Setter>
                            </Style>
     

    Please, find attached below a sample demonstrating this approach based on the provided by you XamBusyIndicator template code. In the sample’s PRBAP_IsNotIndeterminateRoot_Template.xaml Resource dictionary the modification made to the template is on line 84 and consists of setting the FontSize of the TextBlock to “50”.

    If you require any further assistance on the matter, please let me know.

    Best regards,
    Bozhidara Pachilova
    Associate Software Developer