开发者

Visibility.Collapsed is still showing content

I have a custom control that I initially set to collapsed like so

<local:SpriteButton Content="Why?" x:Name="showReason" Click="showReason_Click" Margin="418,12,12,656" Visibility="Collapsed" />

But when I run the app the Content which in this case is "Why?" shows up in there, but the whole UserControl including it's content need to be hidden.

Why is that?

The Sprite Button class looks like this

<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>


    &开发者_运维技巧lt;Button.Style>
        <StaticResource ResourceKey="RectButton"/>
    </Button.Style>

</Button>

SpriteView is yet another custom control that i am using, but that hides correct, it the contentcontrol below it which always shows up.


This question needs more code to show what you mean......

if your trying to hide a child control or container it needs to be hidden with the parent also.

that's at least what it sounds like your asking, please post more so we can help you. :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜