代码之家  ›  专栏  ›  技术社区  ›  Gforse

故事板到值静态资源

  •  0
  • Gforse  · 技术社区  · 6 年前

    这些静态资源我在不同的地方使用,每个设计。现在我想在故事板中使用静态资源进行着色,但我无法使其正常工作,我得到了错误: An object of the type "System.Windows.Media.SolidColorBrush" cannot be applied to a property that expects the type "System.Nullable1[[System.Windows.Media.Color,....]]

    <Application.Resources>
         <SolidColorBrush x:Key="GreenLight" Color="#0CAF12" />
    </Application.Resources>
    

    <Setter Property="Label.Content" Value="Connected" />
    <DataTrigger.EnterActions>
        <BeginStoryboard Name="StoryConnected">
              <Storyboard Storyboard.TargetProperty="(Background).(SolidColorBrush.Color)">
                     <ColorAnimation Storyboard.TargetProperty="(Background).(SolidColorBrush.Color)" To="{StaticResource GreenLight}" Duration="0:0:0.5" />
               </Storyboard>
         </BeginStoryboard>
    </DataTrigger.EnterActions>
    <DataTrigger.ExitActions>
          <RemoveStoryboard BeginStoryboardName="StoryConnected" />
    </DataTrigger.ExitActions>
    
    1 回复  |  直到 6 年前
        1
  •  2
  •   mm8    6 年前

    Storyboard 当您绑定 To

    To="{Binding Color, Source={StaticResource GreenLight}}"
    

    Color

    <Color x:Key="GreenLight">#0CAF12</Color>
    
    推荐文章