【问题标题】:Material Design (WPF): Disable CheckBox AnimationMaterial Design (WPF):禁用复选框动画
【发布时间】:2021-01-31 19:06:08
【问题描述】:

如何禁用MaterialDesignInXAML 中的圆圈/波纹复选框动画?

我尝试了以下设置但没有成功:

md:RippleAssist.IsDisabled="True"
md:RippleAssist.Feedback="Transparent"
md:TransitionAssist.DisableTransitions="True"

【问题讨论】:

    标签: wpf material-design material-design-in-xaml


    【解决方案1】:

    假设您喜欢其中的所有其他功能,我认为您需要重新模板。

    如果您在这里查看 materialdesigninxaml 的来源:

    https://github.com/MaterialDesignInXAML/MaterialDesignInXamlToolkit/blob/master/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.CheckBox.xaml

    (这是巨大的,否则我会把它全部粘贴在这里。)

    您会注意到有一个称为“InteractionEllipse”的椭圆。您可以复制模板并将其撕掉。

                                <Ellipse x:Name="InteractionEllipse" Fill="{TemplateBinding Foreground}" Width="0" Height="0" Canvas.Top="12" Canvas.Left="12" Opacity="0" RenderTransformOrigin="0.5,0.5"
                                         IsHitTestVisible="False">
                                    <Ellipse.RenderTransform>
                                        <TransformGroup>
                                            <ScaleTransform/>
                                            <SkewTransform/>
                                            <RotateTransform/>
                                            <TranslateTransform/>
                                        </TransformGroup>
                                    </Ellipse.RenderTransform>
                                </Ellipse>
    

    点击时会调用一个情节提要,您需要对其进行修改。或者也许只是删除。

                        <Storyboard x:Key="Click">
                            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Width)" Storyboard.TargetName="InteractionEllipse">
                                <EasingDoubleKeyFrame KeyTime="0" Value="0"/>
                                <EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="48"/>
                            </DoubleAnimationUsingKeyFrames>
                            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Height)" Storyboard.TargetName="InteractionEllipse">
                                <EasingDoubleKeyFrame KeyTime="0" Value="0"/>
                                <EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="48"/>
                            </DoubleAnimationUsingKeyFrames>
                            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)" Storyboard.TargetName="InteractionEllipse">
                                <EasingDoubleKeyFrame KeyTime="0" Value="0"/>
                                <EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="-24"/>
                            </DoubleAnimationUsingKeyFrames>
                            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)" Storyboard.TargetName="InteractionEllipse">
                                <EasingDoubleKeyFrame KeyTime="0" Value="0"/>
                                <EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="-24"/>
                            </DoubleAnimationUsingKeyFrames>
                            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="InteractionEllipse">
                                <EasingDoubleKeyFrame KeyTime="0" Value="0.3"/>
                                <EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="0"/>
                            </DoubleAnimationUsingKeyFrames>
                        </Storyboard>
    

    然后要么在你选择的复选框上使用你的新模板,要么用你自己在材料设计之后合并的资源字典中“覆盖”他们的版本。

    另类。

    您也许可以让它使用不同的画笔进行填充。您可以添加附加的依赖属性或动态资源。这样,您可以为部分或全部复选框选择透明,我认为它会消失。

    模板绑​​定到前台

      Fill="{TemplateBinding Foreground}
    

    【讨论】:

    • 非常感谢!我复制了模板并删除了 ButtonBase 的 InteractionEllipse、Storyboard 和 EventTrigger。单击以使其正常工作。
    猜你喜欢
    • 1970-01-01
    • 2015-10-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-06-27
    • 2018-12-24
    • 1970-01-01
    • 2015-01-17
    相关资源
    最近更新 更多