首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Visibility.Collapsed仍在显示内容

Visibility.Collapsed仍在显示内容
EN

Stack Overflow用户
提问于 2011-09-07 23:12:42
回答 1查看 314关注 0票数 1

我有一个最初设置为折叠的自定义控件,如下所示

代码语言:javascript
运行
复制
<local:SpriteButton Content="Why?" x:Name="showReason" Click="showReason_Click" Margin="418,12,12,656" Visibility="Collapsed" />

但是当我运行这个应用程序时,内容是“为什么?”显示在那里,但是包括它的内容在内的整个UserControl都需要隐藏。

为什么会这样呢?

Sprite Button类如下所示

代码语言:javascript
运行
复制
<Button x:Class="AppNameSpace.MyControls.SpriteButton"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:local="clr-namespace:AppNameSpace.MyControls"
    mc:Ignorable="d"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="White"
    Loaded="Button_Loaded"
    HorizontalAlignment="Center" VerticalAlignment="Center"
    MouseLeftButtonDown="Button_MouseLeftButtonDown"
    MouseLeave="Button_MouseLeave"
    ClickMode="Hover"
>

    <Button.Resources>
        <Style x:Key="PhoneButtonCheckBoxBase" TargetType="Button">
            <Setter Property="Background" Value="{StaticResource PhoneRadioCheckBoxBrush}"/>
            <Setter Property="BorderBrush" Value="{StaticResource PhoneRadioCheckBoxBrush}"/>
            <Setter Property="FontSize" Value="{StaticResource PhoneFontSizeMedium}"/>
            <Setter Property="FontFamily" Value="{StaticResource PhoneFontFamilyNormal}"/>
            <Setter Property="HorizontalContentAlignment" Value="Left"/>
            <Setter Property="VerticalContentAlignment" Value="Center"/>
            <!--Setter Property="Padding" Value="-10"/-->
        </Style>
        <Style x:Key="RectButton" TargetType="Button">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="Button">
                        <Grid Background="Transparent">
                            <Grid>
                                <local:spriteView HorizontalAlignment="Center" Sprite="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=currentSprite}" />

                                <ContentControl x:Name="ContentContainer" ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" Foreground="{TemplateBinding Foreground}" FontSize="{TemplateBinding FontSize}" FontFamily="{TemplateBinding FontFamily}" />
                            </Grid>
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </Button.Resources>


    <Button.Style>
        <StaticResource ResourceKey="RectButton"/>
    </Button.Style>

</Button>

SpriteView是我正在使用的另一个自定义控件,但它隐藏正确,它下面的correct控件总是显示出来。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-09-08 05:11:32

这个问题需要更多的代码来显示你的意思......

如果您试图隐藏一个子控件或容器,它也需要与父控件一起隐藏。

这至少听起来像是你的要求,请多发一些,这样我们就可以帮助你了。:)

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/7336248

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档