AnimatedExpander Alternate Style

WPF Studio, Themes, and Shared Library for WPF Forum

Posted 9 years ago by Bob
Version: 9.1.0507
Avatar
Hi,
I have modified the template for you Alternate Style AnimatedExpander in your sample and have got the "helpText" binding. The problem is that I have to create a new template for each different binding I need. Is there a way to make the "helpText" exposed so that I can bind when the style is applied? (hope this makes sense)

        <Style 
            x:Key="AnimatedExpanderAlternateStyle1" 
            TargetType="{x:Type shared:AnimatedExpander}">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="shared:AnimatedExpander">
                        <DockPanel LastChildFill="True">
                            <ToggleButton DockPanel.Dock="Left" Content="{TemplateBinding Header}"
                                    IsChecked="{Binding RelativeSource={RelativeSource TemplatedParent}, 
                                    Path=IsExpanded, Mode=TwoWay}"
                                    Style="{StaticResource AnimatedExpanderToggleButtonStyle}"/>

                            <Border BorderThickness="1" BorderBrush="Transparent"
                                    Background="#D6DCF0"
                                    SnapsToDevicePixels="True">
                                <Grid>
                                    <TextBlock 
                                        x:Name="helpText" 
                                        Text="{Binding Source={x:Static phoenix:Text.Default},
                        Path=preScaler}"
                                        HorizontalAlignment="Center"
                                        VerticalAlignment="Center" />
                                    <shared:AnimatedExpanderDecorator x:Name="content">
                                        <ContentPresenter Content="{TemplateBinding Content}"
                                                ContentTemplate="{TemplateBinding ContentTemplate}"
                                                ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}" Margin="10" />
                                    </shared:AnimatedExpanderDecorator>
                                </Grid>
                            </Border>
                        </DockPanel>

                        <ControlTemplate.Triggers>
                            <Trigger Property="IsExpanded" Value="True">
                                <Setter TargetName="content" Property="IsExpanded" Value="True" />
                                <Setter TargetName="helpText" Property="Visibility" Value="Hidden" />
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
What I want to do is replace the
Text="{Binding Source={x:Static phoenix:Text.Default},Path=preScaler}"
so that I can apply the binding when the STYLE is applied.

Thanks

Comments (2)

Posted 9 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Bob,

You can do one of three things:

1. You can create a new custom class that derives from AnimatedExpander. You would then add a new DependencyProperty to your custom class, and reference that property in the Style. You can still apply the same style, but would need to update the TargetTypes.

2. You can use the Tag property of the AnimatedExpander as the help text. So you'd set the Tag property externally, and bind to that in your control template.

3. Create an attached property and reference that property in your control template.

Hope this helps.


Actipro Software Support

Posted 9 years ago by Bob
Avatar
Thanks,
That was just what I needed!
Bob
The latest build of this product (v2018.1 build 0675) was released 14 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.