Windows phone 8 如何突出显示Longlistselector中的选定项?
我已经在stackoverflow和其他解决方案中搜索并找到了解决方案。我找到了链接 这里我得到的解决方案是,它显示高亮显示的选定项目是供用户控制的 我在longlistselector中只有textblock。如何在longlistselector中突出显示所选项目。我没有在我的页面中使用usercontrol 以下是代码:Windows phone 8 如何突出显示Longlistselector中的选定项?,windows-phone-8,Windows Phone 8,我已经在stackoverflow和其他解决方案中搜索并找到了解决方案。我找到了链接 这里我得到的解决方案是,它显示高亮显示的选定项目是供用户控制的 我在longlistselector中只有textblock。如何在longlistselector中突出显示所选项目。我没有在我的页面中使用usercontrol 以下是代码: <phone:LongListSelector Style="{StaticResource MyTextBlockStyle}" x:Name="MyLongL
<phone:LongListSelector Style="{StaticResource MyTextBlockStyle}" x:Name="MyLongListSelector2" Margin="0,304,-12,0" SelectionChanged="MyLongListSelector2_SelectionChanged" >
<DataTemplate>
<TextBlock x:Name="txtblock"/>
</DataTemplate>
</phone:LongListSelector>
任何想法或链接都会有很大帮助
提前感谢。您是否在更改选择的活动中尝试过此功能
List<TextBlock> userControlList = new List<TextBlock>();
GetItemsRecursive<TextBlock>(MyLongListSelector1, ref userControlList);
// Selected.
if (e.AddedItems.Count > 0 && e.AddedItems[0] != null)
{
foreach (TextBlock txtBlock in userControlList)
{
if (e.AddedItems[0].Equals(txtBlock.DataContext))
{
VisualStateManager.GoToState(txtBlock, "Selected", true);
}
}
}
List userControlList=new List();
GetItemsRecursive(MyLongListSelector1,ref userControlList);
//选中。
如果(e.AddedItems.Count>0&&e.AddedItems[0]!=null)
{
foreach(userControlList中的TextBlock-txtBlock)
{
if(e.AddedItems[0].Equals(txtBlock.DataContext))
{
VisualStateManager.GoToState(txtBlock,“选定”,true);
}
}
}
解决方案取决于您如何实现样式。如果您共享xaml longlistselector及其样式(如果您使用样式)将非常有用。样式与上述链接中的样式相同。VisualStateManager.GoToState上出现错误(txtBlock,“selected”,true);错误是“最佳重载方法匹配…具有一些无效参数…”。。。。