2012-03-22 1 views
0

カスタマイズこれは(あるべきである)単純な質問です。 私はFacebookの通知ボタンのようなコンポーネントを作成したいのですが(そう、あなたがそれをクリックするとドロップダウンメニューが表示され、未読の通知の数の「バッジ」があります)。シルバーComboBoxコンポーネント

トグルボタン内のテキストフィールドと矢印を削除し、キャンバス内にトグルボタンを追加することで、デフォルトのコンボボックスコンポーネント(ポップアップとトグルボタンがあります)をカスタマイズすると思いましたバッジ。

私はいくつかの基本的な動作を「エクスポート」したいし、コンポーネントをスタイリッシュにすることもできます(トグルボタン、バッジ、リスト内の各アイテムのテンプレートを設定するなど)。私のコンポーネントを使用する人々は、それはコンボボックスであるかわからないが、その代わりに、彼らはのように(私のプロパティを設定することができるように、私はどのように私はこれを達成することができます見つけることができません

は...スタイルの「最初」のレベルを作ります"ButtonContent"、 "NotificationItem" と "バッジ")...

ありがとうございました。 Francesco

答えて

0

私はそれが可能である場合は、Microsoftバージョンのスタイルを好む

<UserControl x:Class="silverlight.Components.Notification.View.NotificationSummary" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
      xmlns:vsm="clr-namespace:System.Windows;assembly=System.Windows" 
      xmlns:sys="clr-namespace:System;assembly=mscorlib" 
      xmlns:conv="clr-namespace:silverlight.ViewModel.Converters" 
    mc:Ignorable="d" 
    d:DesignHeight="25" d:DesignWidth="100"> 

    <StackPanel x:Name="LayoutRoot"> 
     <StackPanel.Resources> 
      <conv:NumberToVisibilityConverter x:Key="HasUnreadEventsConverter" /> 
     </StackPanel.Resources> 

     <ToggleButton x:Name="eventButton" Click="notificationButtonClicked"> 
      <ToggleButton.Content> 
       <StackPanel Orientation="Horizontal"> 
        <Border Padding="5 3" VerticalAlignment="Center" HorizontalAlignment="Left"> 
         <ContentPresenter x:Name="buttonContent" /> 
        </Border> 
        <Border x:Name="badge" Padding="5 2" CornerRadius="5" Margin="0 0 5 0" 
           HorizontalAlignment="Right" VerticalAlignment="Center" 
           BorderThickness="1" 
          Visibility="{Binding numberOfUnreadEvents, Converter={StaticResource HasUnreadEventsConverter}}"> 
         <Border.BorderBrush> 
          <SolidColorBrush Color="Black" /> 
         </Border.BorderBrush> 
         <Border.Background> 
          <SolidColorBrush Color="Red"/> 
         </Border.Background> 
         <TextBlock x:Name="badgeText" Text="{Binding numberOfUnreadEvents}"/> 
        </Border> 
       </StackPanel> 
      </ToggleButton.Content> 
     </ToggleButton> 

     <Popup IsOpen="{Binding ElementName=eventButton, Path=IsChecked}" x:Name="notificationPopup"> 
      <Border x:Name="popupBorder" Background="White" CornerRadius="0 0 5 5" 
        Padding="5"> 
       <Border.Effect> 
        <DropShadowEffect BlurRadius="5" Direction="315" ShadowDepth="5" Color="Black" /> 
       </Border.Effect> 
       <ListBox x:Name="eventsList" ItemsSource="{Binding events}" 
         IsHitTestVisible="False"> 
        <ListBox.ItemTemplate> 
         <DataTemplate> 
          <ContentPresenter x:Name="itemTemplate" /> 
         </DataTemplate> 
        </ListBox.ItemTemplate> 
       </ListBox> 
      </Border> 
     </Popup> 
    </StackPanel> 
</UserControl> 
0

サードパーティのコンポーネントの支払いに気にしない場合は、常にRadControls for Silverlight from Telerikです。スイートにはRadDropDownButton controlが含まれています。これはあなたが必要とするものを正確に行うべきだと思います。

+0

(強くコンボボックスに触発)コンボボックスのスタイルを設定するのではなく、新しいコンポーネントを作成しないことを決定しました。.. – Francesco

関連する問題