2011-03-15 61 views
0

我建在Silverlight內部文件的門戶風格的應用程序,Silverlight過濾數據複選框像pivotviewer?

我需要能夠將文件按類別使用複選框像pivotviewer過濾:

要顯示的類別即時通訊使用的ItemsControl和現在使用的哈克變通方法來存儲類別ID ..這樣的文件,可以添加和刪除appropriaely當出頭檢查或未經檢查:

    <ItemsControl x:Name="categoryList" ItemsSource="{Binding}"> 
        <ItemsControl.ItemTemplate> 
         <DataTemplate> 
          <StackPanel Orientation="Horizontal" Margin="2"> 
           <CheckBox Checked="categoryIncluded" Unchecked="categoryExcluded" Content="{Binding ID}"> 
            <CheckBox.ContentTemplate> 
             <DataTemplate> 
              <!-- This is a hack, content is being used to store the id of the category --> 
             </DataTemplate> 
            </CheckBox.ContentTemplate> 
           </CheckBox> 
           <TextBlock Foreground="#FFC2BDBD" Text="{Binding Name}"/> 
          </StackPanel> 
         </DataTemplate> 
        </ItemsControl.ItemTemplate> 
       </ItemsControl> 

這似乎是一個龐大的黑客,

這是通常在Silverlight中完成的嗎?

(我使用RIA數據服務的方式)

回答

1

爲了避免黑客可以創建一個conteins chekbox +其他數據和id屬性

+0

好的建議自定義控件..只是想知道如果theres已經是這樣做的一種方式? – 2011-03-15 16:33:06

+0

你可以用你的viewmodel綁定IsCheked屬性來做到這一點,並通知過濾器當這個變化,因爲你在你的viewmodel youalredy有id值存在 – kalvis 2011-03-15 16:40:59

+0

很酷的感謝..我結束了子類化複選框,只是添加字段:) – 2011-03-15 16:47:57