2014-04-07 45 views
3

我試圖在調試期間直接使用IsSelected設置爲true(不包括綁定)問題(最後我嘗試使用綁定,但有發現,即使不帶W/O綁定這不起作用)。ListView.ItemContainerStyle IsSelected屬性似乎不會影響WinRT上的選擇

以下代碼在WPF(所有項目選擇)中工作正常,但在WinRT上無效(執行後未選擇任何項目)。

這是一個錯誤/功能?

下面的XAML將在WPF窗口,並在WinRT的頁面編譯..

<ListView SelectionMode="Multiple" HorizontalAlignment="Stretch"> 
     <ListView.ItemContainerStyle> 
      <Style TargetType="ListViewItem"> 
       <Setter Property="IsSelected" Value="True"/> 
      </Style> 
     </ListView.ItemContainerStyle> 
     <TextBox Width="200"/> 
     <TextBox Width="200"/> 
     <TextBox Width="200"/> 
     <TextBox Width="200"/> 
     <TextBox Width="200"/> 
    </ListView> 

回答

0

您可以使用預定義的DataTemplate爲listviewItem.Hope這有助於

<ListView SelectionMode="Multiple"> 
    <ListView.ItemContainerStyle> 
     <Style TargetType="ListViewItem"> 
      <Setter Property="HorizontalContentAlignment" Value="Stretch"/> 
      <Setter Property="ContentTemplate"> 
       <Setter.Value> 
        <DataTemplate> 
         <ListViewItem IsSelected="True" > 
          <TextBox Height="30" Width="200" ></TextBox> 
         </ListViewItem> 
        </DataTemplate> 
       </Setter.Value> 
      </Setter> 
     </Style> 
    </ListView.ItemContainerStyle> 
    <TextBox /> 
    <TextBox/> 
    <TextBox/> 
    <TextBox/> 
    <TextBox/>   
</ListView> 
+0

這一工作解決了這個問題。謝謝。現在看看它是否會與綁定。 :) –

+0

嗯..不,它沒有...你在樣式中添加了一個TextBox - 我可能有一組不同的控件(或綁定控件)。它也不能與綁定,看起來像.. :( –

+0

其datatemplate只,我認爲它應該與數據綁定工作,但在你的情況下,也許其他控制依賴關係創建數據綁定的問題。不確定.thanks。 –

相關問題