基於您的代碼,我不知道邊境是一個ListViewItem的模板中,如果是的話請去以下路徑:C:\ Program Files文件(x86)的\的Windows套件\ 10 \設計時\ CommonConfiguration \ Neutral \ UAP \ 10.0.14393.0 \ Generic \ generic.xaml以獲取所有UWP控件的所有默認樣式。 然後請搜索ListViewItem樣式,您會發現兩個ListViewItem樣式,請將名稱爲ListViewItemExpanded的樣式複製到您的項目中,並將邊框添加到ListViewItemExpanded樣式中。
後,爲了改變邊框背景時ListViewItem的選擇,請搜索選擇/ PointerOverSelected/PressedSelected的VisualState並添加以下XAML代碼裏面改變顏色:
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="myback" Storyboard.TargetProperty="Background">
<DiscreteObjectKeyFrame KeyTime="0" Value="Red" />
</ObjectAnimationUsingKeyFrames>