- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我正在编写一个播放流媒体音乐的应用程序,在应用程序中我有很多列表(排名列表、搜索结果列表、精选歌曲列表......),每个列表都有一个相同的数据模板,我将其绑定(bind)到 LongListSelector对于每个页面。所以我将这个数据模板用作资源并将其放在 app.xaml 中
<DataTemplate x:Key="BasicVideoTemplate">
<Grid Tap="ChangeSong_Tap" RowsAuto="50,50" ColumnsAuto="150,*" Background="White" Margin="5,0,5,10">
<Grid.ColumnDefinition>
<ColumnDefinition Width = "150"/>
<ColumnDefinition Width = "*"/>
</Grid.ColumnDefinition>
<Grid.RowDefinition>
<RowDefinition Height = "50"/>
<RowDefinition Height = "50"/>
</Grid.RowDefinition>
<Border BorderThickness="1" BorderBrush="Black" Grid.RowSpan="2" Grid.Column="0" VerticalAlignment="Center" Margin="5,0,5,0">
<Image Source="{Binding Cover}"/>
</Border>
<TextBlock Text="{Binding Name}" Grid.Row="0" Grid.Column="1" Style="{StaticResource BlackTextBlock}" Margin="5,0,0,0"/>
<TextBlock Text="{Binding Artist}" Grid.Row="1" Grid.Column="1" Foreground="Black" Margin="5,0,0,0"/>
<!-- .............. -->
</Grid>
</DataTemplate>
和这段代码(我放在 app.xaml.cs 中)从列表中选择一首歌曲,从这个项目创建一个 AudioTrack 并导航到 playSongPage:
private void ChangeSong_Tap(object sender, System.Windows.Input.GestureEventArgs e)
{
var item = (SongItemModel)(sender as FrameworkElement).DataContext;
App.Model.ChangeSong(item.Id); /// this code will create a audio track for this item
(Application.Current.RootVisual as PhoneApplicationFrame).Navigate(new Uri("/Pages/DetailSongPage.xaml", UriKind.Relative));
}
这里的问题是,我必须为我的播放列表创建一个 List
最佳答案
我会在每个 longlistselector
的 SelectionChanged
事件中处理它。网格上的整个 Tap 东西不适合我。
<phone:LongListSelector x:Name="myLSS" SelectionChanged="myLSS_SelectionChanged"/>
// event handler changes to
private void myLSS_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
LongListSelector lls = sender as LongListSelector; // get lls
var item = (SongItemModel) lls.SelectedItem;
App.Model.ChangeSong(item.Id); /// this code will create a audio track for this item
// now your ObservableCollection is just the ItemsSource, save a reference to it
// in the State manager so you can reference it on another page if you wish
ObservableCollection<SongItemModel> obs = (ObservableCollection<SongItemModel>) lls.ItemsSource;
PhoneApplicationService.Current.State["current_obs"] = obs;
// navigate..............
(Application.Current.RootVisual as PhoneApplicationFrame).Navigate(new Uri("/Pages/DetailSongPage.xaml", UriKind.Relative));
}
关于c# - 获取选择的 Item 的父 ObservableCollection - WP8,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25966912/
我正在尝试在我正在处理的博客上使用类别帖子 (WP-CPL) 插件来按类别过滤“最近的帖子”。基本上,当有人点击博客上的类别名称时,我希望它显示该类别的帖子。这将通过 Life Is Simple 模
我的形象 我只想为某些用户隐藏特定页面。 function remove_menus(){ // get current login user's role $roles = wp_g
我的形象 我只想为某些用户隐藏特定页面。 function remove_menus(){ // get current login user's role $roles = wp_g
我为我的 wp 网站创建了一个简单的脚本,我正在尝试从 2 个表的 wp 数据库中获取正确的数据,这是代码, 当我显示“user_ref_id”列的结果重复多次时,这是代码 global $wpdb;
我安装了一个名为 Hide My WP 的插件来更改网站结构,但考虑到我使用的是自定义主题,它破坏了一些功能。所以我手动从plugins文件夹中删除了插件,但是从那以后我就无法访问/wp-admin/
我试图从头开始创建 WXR 文件(WordPress eXtended Rss)。 我的代码基于 XML/ wordpress生成的WXR文件并像这样开始: 我是这样开始的: $newxml =
我想将所有页面重定向到 http://www.expample2.com除了 wp-admin 和 wp-json。 例如,用户能够登录 http://www.example1.com/wp-admi
我使用 MAMP 在本地构建了一个快速的 WordPress 网站,然后将其 checkin SVN 存储库。然后我将其检查到我的开发服务器上。 除了运行 search and replace too
在搜索端点的 WP REST API (wp json) 中: https://www.example.com/wp-json/wp/v2/search?search=searchPhrase&_em
我正在使用这个 NGINX 规则来强制 WordPress 网站的尾部斜杠: rewrite ^([^.]*[^/])$ $1/ permanent; 但是这个规则给 Gutenberg 和 wp-j
在搜索端点的 WP REST API (wp json) 中: https://www.example.com/wp-json/wp/v2/search?search=searchPhrase&_em
我正在使用这个 NGINX 规则来强制 WordPress 网站的尾部斜杠: rewrite ^([^.]*[^/])$ $1/ permanent; 但是这个规则给 Gutenberg 和 wp-j
我想限制所有用户访问 WordPress 网站登录。 例如:假设我有 WordPress 网站域 example1.com,我想限制所有用户使用 example1.com/wp- 访问管理员登录adm
尝试实现这里讨论的技术, http://z9.io/2013/10/21/shiny-new-dynamic-content-wp-super-cache/ 进入使用 Genesis 框架的站点。我想
我试图在位于我的 WP 主题文件夹内的 PHP 文件中调用自定义 AJAX 函数,但是我无法让它检索输出。我认为问题在于将 WP 查询链接到主 WP 文件? $.ajax({ url: "../../
我正在编写一个 perl 脚本,用于将 Wordpress 安装从一个地方迁移到另一个地方。在这项工作中,我需要使用 wp-cli 调用从 wp-config 文件中获取 wordpress 数据库名
我最近更改了我的 WordPress 网站上的目录。我导出了数据库,搜索并替换了旧 URL 为新 URL,然后重新导入。该网站的前端工作正常,但任何页面的后端都需要近 15 秒才能加载。 从funct
我使用下面的代码通过类似的单词标签获取帖子但不起作用 $query = " SELECT * FROM $wpdb->posts , $wpdb->terms
我已经通过 DirectAdmin 在我的服务器上安装了 SSL 证书。这似乎运作良好。 我已将 wp_*_options 表中的 url 更改为 https://mydomain.nl 等。突然我的
我正在建立一个网站,使用 wordpress+buddypress(最新版本)。 在这个网站中,我有自己的自定义登录|注册|重置密码表单,我不想将它们链接到后端 wp-forms。 我已经阻止了所有用
我是一名优秀的程序员,十分优秀!