我正在尝试淡入然后淡出标签,它似乎适用于我的代码的某些部分,但不适用于其他部分..
所以,对于 xaml 我有:
<Page x:Class=""Gtec2.MindBeagle.ChoosePatient" .. .bla bla bla>
<Page.Resources>
<Resources Dictionary>
<Storyboard x:Key="fadeInStory" Storyboard.TargetName="noPatientsLabel" Storyboard.TargetProperty="Opacity">
<DoubleAnimation From="1" To="0" Duration="0:0:0.300"/>
</Storyboard>
<!-- Other resources as imagesources, styles and stuff -->
</Resources Dictionary>
</Page.Resources>
<Grid>
<!-- A lot of things -->
<!-- And the guy I want to fadeIn and Out-->
<TextBlock Name="noPatientsLabel" TextAlignment="Center" VerticalAlignment="Center" Grid.Column="1" Grid.Row="1" IsHitTestVisible="False">
No Patients found <LineBreak/>
please check the filters
</TextBlock>
<!-- A lot of things -->
</Grid>
</Page>
对于背后的代码(C#),我有很多东西和一个像这样的方法:
public void FadeIn()
{
Storyboard sb = FindResource("fadeInStory") as Storyboard;
sb.Begin();
}
IT 似乎在同一个 cs 文件中工作,但是当其他操作调用此方法以显示标签时,它会抱怨说“在 'Gtec2.MindBeagle.ChoosePatient' 的名称范围内找不到'noPatientsLabel' 名称。”
想法?