내 ChildWindow 서브 클래스와 함께 VisualStateManager를 사용할 수있는 방법이 있습니까? VisualStateManager에 대한 호출은 아무 것도하지 않으며,이를 수행하는 유일한 방법은 스토리 보드를 수동으로 호출하는 것입니다. 너무나 가볍고 실수하기 쉽습니다. 누구든지 그것을 성취 할 방법을 찾았습니까?ChildWindow에서 VisualStates를 사용하려면 어떻게해야합니까?
예제 코드으로 업데이트되었습니다. 이를 사용하려면 새 Silverlight 프로젝트를 만들고 기본 페이지에서 단추를 클릭하여 ExampleWindow.ShowWindow()를 호출하면됩니다. 생성자가 버튼을 숨겨야하는 상태를 설정하더라도 버튼을 볼 수 있습니다.
XAML (ExampleWindow.xaml) :
<controls:ChildWindow
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
xmlns:ic="clr-namespace:Microsoft.Expression.Interactivity.Core;assembly=Microsoft.Expression.Interactions"
x:Class="Client.Windows.ExampleWindow"
Title="Example">
<Grid x:Name="LayoutRoot">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="ExampleStateGroup">
<VisualState x:Name="ExampleBaseState">
<Storyboard>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="button" Storyboard.TargetProperty="(UIElement.Opacity)">
<EasingDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<VisualStateManager.CustomVisualStateManager>
<ic:ExtendedVisualStateManager/>
</VisualStateManager.CustomVisualStateManager>
<Button x:Name="button" Content="You Shouldn't See Me" Grid.ColumnSpan="2" Width="150" Height="150" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Grid>
</controls:ChildWindow>
코드 뒤에 (ExampleWindow.xaml.cs) :
using System.Windows;
using System.Windows.Controls;
namespace Client.Windows
{
public partial class ExampleWindow : ChildWindow
{
public ExampleWindow()
{
InitializeComponent();
VisualStateManager.GoToState(this, "ExampleBaseState", true);
}
public static void ShowWindow()
{
var w = new ExampleWindow();
w.Show();
}
}
}
ChildWindow가 VisualStateManager를 사용할 수없는 이유를 생각할 수 없습니다. 코드의 일부를 보여 주어야합니까? – AnthonyWJones
ChildWindow의 템플릿에 Open 및 Closed VisualStates가있어서 VisualStateGroups에 대한 VisualTree 검색이 멈추고 컨트롤의 상태가 지속되지 않는다고 생각합니다. (디자인 타임에 Blend에서 제대로 작동하지만). – Dov