子控件不能隐藏在双动画画布高度中 [英] child control not hide in double animation canvas height

查看:65
本文介绍了子控件不能隐藏在双动画画布高度中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想像accordian那样开发控制,因为当按钮点击时我将高度动画应用到画布

但是我在画布中有一些控件,双动画正在工作文件画布高度属性是redusing and increase,

但是当画布高度属性减少时,子控件不会隐藏到该画布高度,

所以我想将该子控件隐藏为画布高度属性减少



这是我的xaml代码,



 < span class =code-keyword><   Window     x:Class   =  WpfApplication2.MainWindow  

xmlns = http://schemas.microsoft.com/winfx/2006/xaml/presentation

xmlns:x < span class =code-keyword> = http://schemas.microsoft.com/winfx/2006/xaml

< span class =code-attribute> 标题 = MainWindow 高度 = 600 宽度 = 525 >


< 画布 宽度 = 500 高度 = 450 >
< < span class =code-leadattribute> StackPanel
宽度 = 500 高度 = 450 >
< 按钮 宽度 = 500 高度 = 25 点击 < span class =code-keyword> = Button_Click_1 > < /按钮 >
< span class =code-keyword>< Canvas x:Name = cnvOrng 宽度 = 500 背景 = 橙色 >
< StackPanel >
< StackPanel >
< 按钮 样式 = {StaticResource type-btn} >
< StackPanel 方向 = 水平 样式 = {StaticResource type-button-sp} >
< 图片 来源 = 图片/支票.png 样式 = {StaticResource check-image} > < ; / Image >
< TextBlock 样式 = {StaticResource type-Text} > 01 < / TextBlock >
< / StackPanel >
< /按钮 >
< span class =code-keyword>< 按钮 样式 = {StaticResource type-btn} >
< StackPanel Orientation = 水平 样式 = {StaticResource type-button-sp} >
< 图片 来源 = Images / check.png 样式 = { StaticResource check-image} > < / Image >
< TextBlock 样式 = {StaticResource type-Text} > 02 < / TextBlock >
< / StackPanel >
< /按钮 >
< 按钮 样式 = {StaticResource type-btn} >
< StackPanel 方向 = 水平 样式 = {StaticResource type -button-sp} >
< 图像 来源 = Images / check.png 样式 = {StaticResource check-image} > < / Image >
< TextBlock 样式 = {StaticResource type-Text} > 03 < / TextBlock >
< / StackPanel >
< /按钮 >


< / StackPanel < span class =code-keyword>>
< / StackPanel >

< / Canvas >

< / StackPanel >
< < span class =code-leadattribute> / Canvas >
< / Window >





谢谢。

解决方案

使用stackpanel而不是canvas


I want develope control like accordian, for that I applies the height animation to canvas when button is click
but I have some controls in that canvas, double animation is working file the canvas height property is redusing and increasing,
but when canvas height property is reduce the child controls are not hide accroding to that canvas height,
so I want to hide that child controls as the canvas height property reducing

here is my xaml code,

<Window x:Class="WpfApplication2.MainWindow"

        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

        Title="MainWindow" Height="600" Width="525">
  
    
    <Canvas Width="500" Height="450">
        <StackPanel Width="500" Height="450">
            <Button Width="500" Height="25" Click="Button_Click_1"></Button>
            <Canvas x:Name="cnvOrng" Width="500"  Background="Orange">
                <StackPanel>
                    <StackPanel>
                        <Button Style="{StaticResource type-btn}">
                            <StackPanel Orientation="Horizontal" Style="{StaticResource type-button-sp}">
                                <Image Source="Images/check.png" Style="{StaticResource check-image}"></Image>
                                <TextBlock Style="{StaticResource type-Text}">01</TextBlock>
                            </StackPanel>
                        </Button>
                        <Button Style="{StaticResource type-btn}">
                            <StackPanel Orientation="Horizontal" Style="{StaticResource type-button-sp}">
                                <Image Source="Images/check.png" Style="{StaticResource check-image}"></Image>
                                <TextBlock Style="{StaticResource type-Text}">02</TextBlock>
                            </StackPanel>
                        </Button>
                        <Button Style="{StaticResource type-btn}">
                            <StackPanel Orientation="Horizontal" Style="{StaticResource type-button-sp}">
                                <Image Source="Images/check.png" Style="{StaticResource check-image}"></Image>
                                <TextBlock Style="{StaticResource type-Text}">03</TextBlock>
                            </StackPanel>
                        </Button>
                      
                    </StackPanel>
                </StackPanel>

            </Canvas>
          
        </StackPanel>
    </Canvas>
</Window>



Thanks.

解决方案

use stackpanel instead of canvas


这篇关于子控件不能隐藏在双动画画布高度中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆