2011-07-28 20 views
0

我正在處理最初由其他人創建的項目,他們有一個xaml資源字典,其中包含整個解決方案中使用的所有按鈕樣式。在Silverlight中預覽資源的模板結果

我在解決方案中重新設計了一個窗口,它真的可以幫助我知道哪些按鈕看起來像是什麼,因此我知道哪些可以在其他地方工作,因此我可以清除適合新按鈕的樣式我正在努力。

我的問題是有超過30種不同的按鈕樣式可以查看。

是否有人知道預覽應用樣式到其targetType的結果的好方法?它不需要很簡單,只是希望儘可能簡單。

note我試過表達,我沒有在那裏看到一個選項,但我沒有真正嘗試過它。

現在我能想到的最好的事情就是創建一個只包含一個按鈕的空白窗口,然後輸入我想查看的樣式,直到找到我想要的樣式。有人有更好的系統嗎?

我在下面包括一個樣式的例子,以防萬一它有幫助,但它看起來像它本身有很多依賴關係。我只在Silverlight的第2個月,所以經過下面的30+是有點令人生畏。

<Style TargetType="Button" x:Key="RightButtonBarButtonStyle"> 
     <Setter Property="Padding" Value="15,0,15,0" /> 
     <Setter Property="Foreground" Value="White"/> 
     <Setter Property="FontFamily" Value="Segoie"/> 
     <Setter Property="FontSize" Value="13"/> 
     <Setter Property="Padding" Value="3"/> 
     <Setter Property="BorderThickness" Value="1"/> 
     <Setter Property="BorderBrush"> 
      <Setter.Value> 
       <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0"> 
        <GradientStop Color="#FFA3AEB9" Offset="0"/> 
        <GradientStop Color="#FF8399A9" Offset="0.375"/> 
        <GradientStop Color="#FF718597" Offset="0.375"/> 
        <GradientStop Color="#FF617584" Offset="1"/> 
       </LinearGradientBrush> 
      </Setter.Value> 
     </Setter> 
     <Setter Property="Template"> 
      <Setter.Value> 
       <ControlTemplate TargetType="Button"> 
        <Grid x:Name="grid" RenderTransformOrigin="0.5,0.5" Height="25"> 
         <Grid.RenderTransform> 
          <CompositeTransform/> 
         </Grid.RenderTransform> 
         <VisualStateManager.VisualStateGroups> 
          <VisualStateGroup x:Name="CommonStates"> 
           <VisualStateGroup.Transitions> 
            <VisualTransition GeneratedDuration="0:0:0.2"> 
             <VisualTransition.GeneratedEasingFunction> 
              <CubicEase EasingMode="EaseOut"/> 
             </VisualTransition.GeneratedEasingFunction> 
            </VisualTransition> 
           </VisualStateGroup.Transitions> 
           <VisualState x:Name="Normal"/> 
           <VisualState x:Name="MouseOver"> 
            <Storyboard> 
             <DoubleAnimation Duration="0" To="0.7" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="grid" d:IsOptimized="True"/> 
            </Storyboard> 
           </VisualState> 
           <VisualState x:Name="Pressed"> 
            <Storyboard> 
             <DoubleAnimation Duration="0" To="0.98" Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.ScaleX)" Storyboard.TargetName="grid" d:IsOptimized="True"/> 
             <DoubleAnimation Duration="0" To="0.98" Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.ScaleY)" Storyboard.TargetName="grid" d:IsOptimized="True"/> 
             <DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="DisabledVisualElement" d:IsOptimized="True"/> 
            </Storyboard> 
           </VisualState> 
           <VisualState x:Name="Disabled"> 
            <Storyboard> 
             <DoubleAnimation Duration="0" To="0.5" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="DisabledVisualElement"/> 
            </Storyboard> 
           </VisualState> 
          </VisualStateGroup> 

          <VisualStateGroup x:Name="FocusStates"> 
           <VisualState x:Name="Focused"/> 
           <VisualState x:Name="Unfocused"/> 
          </VisualStateGroup> 
         </VisualStateManager.VisualStateGroups> 
         <Border x:Name="border" BorderBrush="{StaticResource CoreButtonBorderBrush}" BorderThickness="0,1,1,1" CornerRadius="0,15,15,0" Background="{StaticResource CoreButtonBackgroundBrush}"/> 
         <ContentPresenter x:Name="contentPresenter" ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="10,0,10,0" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/> 
         <Border BorderBrush="Black" BorderThickness="0" Height="1" Margin="11,1,11,0" VerticalAlignment="Top" Background="{StaticResource CoreButtonTopLineBrush}"/> 
         <Border BorderBrush="Black" BorderThickness="0" Height="1" Margin="12,0,13,-1" Background="{StaticResource CoreButtonBottomLineBrush}" VerticalAlignment="Bottom" Opacity="0.5"/> 
         <Border x:Name="DisabledVisualElement" Background="Black" IsHitTestVisible="false" Opacity="0" CornerRadius="0,15,15,0" /> 

        </Grid> 
       </ControlTemplate> 
      </Setter.Value> 
     </Setter> 
    </Style> 

編輯 看來我是太迅速解僱的表達。默認情況下(我假設默認情況下)程序右側有一個資源選項卡(屬性和數據旁邊)。如果沒有打開,您可以進入菜單並選擇Window-> Resources。

從此處顯示按xaml文件分組的所有資源,以便按照相應名稱右側的按鈕預覽樣式的外觀。只有一種按鈕類型沒有正確顯示(聲稱有一個重複的按鍵名稱,不明白爲什麼會阻止預覽,但確實如此,所以我猜其他併發症會導致類似的結果)。

我目前正在四處尋找VS2010,看看我是否可以找到類似的功能,但我現在懷疑是否有,因爲這似乎更多的表達的東西。

因此,如果有人知道Visual Studio 2010中存在的功能,請讓我知道,因爲這將使我無需在項目之間跳轉,並在開始編輯時刷新項目。如果可以的話,我也想避免購買Expression。

回答

0

看起來我很快就駁回了表達式。默認情況下(我假設默認情況下)程序右側有一個資源選項卡(屬性和數據旁邊)。如果沒有打開,您可以進入菜單並選擇Window-> Resources。

從此處顯示按xaml文件分組的所有資源,以便按照相應名稱右側的按鈕預覽樣式的外觀。只有一種按鈕類型沒有正確顯示(聲稱有一個重複的按鍵名稱,不明白爲什麼會阻止預覽,但確實如此,所以我猜其他併發症會導致類似的結果)。

我目前正在四處尋找VS2010,看看我是否可以找到類似的功能,但我現在懷疑是否有,因爲這似乎更多的表達的東西。

因此,如果有人知道Visual Studio 2010中存在的功能,請讓我知道,因爲這將使我無需在項目之間跳轉,並在開始編輯時刷新項目。如果可以的話,我也想避免購買Expression。