2014-07-04 9 views
0

도구 모음의 첫 번째 버튼 이미지에 적용되지 않습니다이미지 스타일이 나는 Window.Resources에 배치 내 이미지에 대한 스타일을

 <ToolBarTray DockPanel.Dock="Top" Background="Transparent"> 
      <ToolBar Band="0" BandIndex="0" x:Name="ToolbarCATIAAccess" Background="{DynamicResource linearGradBrushHellaTitanMenu}"> 
       <Button Name="ButtonInsertIntoProduct"> 
        <Image x:Name="ImageInsertIntoProduct" Source="/HKBEStandardsFromPDMLibrary;component/Resources/InsertIntoCATIAProduct.png" 
          ToolTip="insert files into active CATIA Product"/> 
       </Button> 
       <Button Name="ButtonCopyFilesToWIN"> 
        <Image x:Name="ImageCopyFilesToWIN" Source="/HKBEStandardsFromPDMLibrary;component/Resources/CopyFilesToWIN.png" 
          ToolTip="copy files to WIN folder"></Image> 
       </Button> 
      </ToolBar> 
     </ToolBarTray> 

:

<Style TargetType="{x:Type Image}"> 
     <Style.Triggers> 
      <Trigger Property="IsEnabled" Value="False"> 
       <Setter Property="Opacity" Value="0.3" /> 
      </Trigger> 
     </Style.Triggers> 
    </Style> 

나는 도구 모음이 이 스타일은 전체 창과 다른 응용 프로그램의 모든 이미지에 적용됩니다. 그러나 툴바의 첫 번째 이미지에는 작동하지 않으며 어떤 이미지가 먼저 나오는지는 중요하지 않습니다. 처음에는 불투명도가 설정되지 않습니다. 첫 번째 이미지로 숨겨진 (버튼) 이미지를 툴바에 추가하면 첫 번째 이미지가 표시됩니다.

not working Style

... 
       <Button Name="ButtonCopyFilesToWIN_" Visibility="Collapsed"> 
        <Image x:Name="ImageCopyFilesToWIN_" Source="/HKBEStandardsFromPDMLibrary;component/Resources/CopyFilesToWIN.png" 
          ToolTip="copy files to WIN folder"></Image> 
       </Button> 
       <Button Name="ButtonInsertIntoProduct"> 
        <Image x:Name="ImageInsertIntoProduct" Source="/HKBEStandardsFromPDMLibrary;component/Resources/InsertIntoCATIAProduct.png" 
          ToolTip="insert files into active CATIA Product"/> 
       </Button> 
       ... 

working Style

여기 사람이 문제가 될 수 나를 도울 수있는 어떤 생각을 가지고 있습니까? 감사합니다.

+1

수행 ** 모든 ** 도구 모음 단추는''의 IsEnabled = "거짓"이 ? 이를 확인 했습니까 (예 : [Snoop] (http://snoopwpf.codeplex.com/))? –

답변

1

나는 리소스와 툴바 코드 스 니펫을 가져 와서 작동하는지 여부를 증명할 수있는 간단한 앱에 배치하고 예제에서 예상대로 동작합니다. 이미지가 사라지면 불투명도를 0으로 변경했습니다.

스 니펫에있는 이미지는 내 샘플 이미지이며, 원래 이미지로 되돌립니다. 아래 스 니펫의 이미지에서 IsEnabled 속성을 명시 적으로 설정하면 스타일이 적용되고 있는지 확인할 수 있습니다. 여기서 두 번째 이미지가 사라지고 (IsEnabled가 false이고 스타일의 불투명도를 0으로 설정) 이미지의 IsEnabled 속성을 바꿔 두 번째 이미지가 참이고 첫 번째 이미지가 거짓이면 첫 번째 이미지가 사라지면 두 번째 이미지가 사라집니다. 그래서 스타일은 아래에 표시된 기본 예제 응용 프로그램에 적용됩니다. 예를 들어, 응용 프로그램에서

<Window.Resources> 
    <ResourceDictionary> 
     <ResourceDictionary.MergedDictionaries> 
      <ResourceDictionary Source="Dictionary1.xaml" /> 
     </ResourceDictionary.MergedDictionaries> 
    </ResourceDictionary> 
</Window.Resources> 
<Grid> 
    <ToolBarTray DockPanel.Dock="Top" Background="Transparent"> 
     <ToolBar Band="0" BandIndex="0" x:Name="ToolbarCATIAAccess" > 
      <Button Name="ButtonInsertIntoProduct"> 
       <Image x:Name="ImageInsertIntoProduct" Source="scroll1.png" IsEnabled="True" 
         ToolTip="insert files into active CATIA Product"/> 
      </Button> 
      <Button Name="ButtonCopyFilesToWIN"> 
       <Image x:Name="ImageCopyFilesToWIN" Source="scroll2.png" IsEnabled="False" 
         ToolTip="copy files to WIN folder"></Image> 
      </Button> 
     </ToolBar> 
    </ToolBarTray> 
</Grid> 

만 다른 코드 (Dictionary1.xaml - 리소스 사전 파일) :

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
       xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> 
<Style TargetType="{x:Type Image}"> 
    <Style.Triggers> 
     <Trigger Property="IsEnabled" Value="False"> 
      <Setter Property="Opacity" Value="0" /> 
     </Trigger> 
    </Style.Triggers> 
</Style> 

+0

감사합니다 'Mal'! 그래서 그것은 내 애플 리케이션의 다른 문제로 보인다. 아니면 코드에서 isenabled 상태를 설정하는 것만으로도 문제가 될 수 있습니다! – Crow1973

+0

이상한! 예제 응용 프로그램에 이것을 추가하고 작동합니다. 하지만 현재의 응용 프로그램에는 없습니다. 하지만 다시 'Mal'. – Crow1973