我創建了一個列表框,我可以根據該列表框動態添加和刪除項目UI相應的更改,並且工作正常。在列表框中更改項目屬性時遇到的問題
<ListBox Name="MsgsList" ItemsSource="{Binding Items}" Style="{StaticResource MsgsBoxStyle}">
<ListBox.ItemTemplate>
<DataTemplate x:Name="MsgsDataTemplate">
<StackPanel Tag="{Binding MsgTagInfo}" ManipulationCompleted="StackPanel_Msgs_ManipulationCompleted">
<toolkit:GestureService.GestureListener>
<toolkit:GestureListener Hold="GestureListener_Hold" Tap="GestureListener_Tap"/>
</toolkit:GestureService.GestureListener>
<Grid x:Name="ContentPanelInner" Grid.Row="1" Width="500">
<StackPanel x:Name="stackPanelInner" Width="500">
<Grid VerticalAlignment="Top" Width="500">
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0" Text="{Binding MsgTitle}" Style="{StaticResource MsgLine1}" />
<TextBlock Grid.Column="1" Text="{Binding MsgDate}" Style="{StaticResource MsgDate}" />
</Grid>
<TextBlock Text="{Binding MsgBody}" Style="{StaticResource MsgLine2}" />
</StackPanel>
</Grid>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
,但我不知道如何改變風格爲特定項目的文本塊,亦即基於某些情況下,如果我想改變特定項目的文本框(S)的顏色不知道如何訪問。
有人可以幫我這個嗎?謝謝。
這就是我將如何做一個非常簡單的例子,但我傾向於使用轉換器來處理任何不平凡的事情,因爲它有助於從視圖中分離模型。 – ZombieSheep 2012-02-01 14:48:10
謝謝你的簡單回答。 – rplusg 2012-02-02 10:07:57