home
products
contribute
download
documentation
forum
Home
Forums
New posts
Search forums
What's new
New posts
All posts
Latest activity
Members
Registered members
Current visitors
Donate
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Search titles only
By:
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
MediaPortal 2
Plugin Development
ListView command binding and Item labels
Contact us
RSS
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="FreakyJ" data-source="post: 1153748" data-attributes="member: 106003"><p>[USER=48495]@morpheus_xx[/USER] </p><p>I thought I would start working on a little Inputmanager, because this is requested by many people <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite1" alt=":)" title="Smile :)" loading="lazy" data-shortname=":)" /></p><p>It is a bit how you doing, but anyway^^</p><p></p><p>First problem:</p><p>I can add Items to the Listview and the Items shown, but without any text <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite3" alt=":(" title="Frown :(" loading="lazy" data-shortname=":(" /> I tried to read in other plugins, but I think I did it exactly the same, but it just doesn't work :/</p><p>See attached Screenshot.</p><p>The code looks liek this:</p><p>[CODE=XML]<?xml version="1.0" encoding="utf-8"?></p><p><Include</p><p> xmlns="www.team-mediaportal.com/2008/mpf/directx"</p><p> xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"</p><p> Source="screens\master_menu.xaml"</p><p> ></p><p> <Include.Resources></p><p> <ControlTemplate x:Key="Contents_Template"></p><p> <Grid></p><p> <!-- Model = MediaNavigationModel --></p><p> <Grid.Resources></p><p> <Model x:Key="MediaModel" Id="CC11183C-01A9-4F96-AF90-FAA046981006"/></p><p> </Grid.Resources></p><p> <Grid.RowDefinitions></p><p> <RowDefinition Height="*"/></p><p> </Grid.RowDefinitions></p><p> <Grid.ColumnDefinitions></p><p> <ColumnDefinition Width="*"/></p><p> </Grid.ColumnDefinitions></p><p> <Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch" IsVisible="true"></p><p> <Grid.RowDefinitions></p><p> <RowDefinition Height="*"/></p><p> </Grid.RowDefinitions></p><p> <Grid.ColumnDefinitions></p><p> <ColumnDefinition Width="*"/></p><p> </Grid.ColumnDefinitions></p><p></p><p> <ListView Context="{Model Id=CC11183C-01A9-4F96-AF90-FAA046981006}" Style="{StaticResource ContentsMenuListViewStyle}" ItemsSource="{Binding Path=Items,Mode=OneTime}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" IsVisible="true"></p><p> <ListView.Resources></p><p> <!--<Command x:Key="Menu_Command" Source="{StaticResource MediaModel}" Path="Select"</p><p> Parameters="{LateBoundValue BindingValue={Binding}}"/>--></p><p> <CommandBridge x:Key="Menu_Command" Command="{Binding Path=Command,Mode=OneTime}"/></p><p> </ListView.Resources></p><p> </ListView></p><p> <Button Context="{Model Id=CC11183C-01A9-4F96-AF90-FAA046981006}" Content="Add" Style="{ThemeResource ButtonWideStyle}" Margin="10"</p><p> HorizontalAlignment="Right" VerticalAlignment="Center"</p><p> Command="{Command AddKeyMapping}"/></p><p> </Grid></p><p> </Grid></p><p> </ControlTemplate></p><p> </Include.Resources></p><p></Include>[/CODE]</p><p></p><p>And the creation of the ListItems:</p><p></p><p>[code]protected ItemsList _items;</p><p>public ItemsList Items</p><p> {</p><p> get { return _items; }</p><p> }</p><p></p><p>private void InitModel()</p><p> {</p><p>_items = new ItemsList();</p><p></p><p>[....]</p><p></p><p>var tmp = new ListItem();</p><p> tmp.SetLabel("asdda", "sadas");</p><p> tmp.SetLabel("dsfsdf", "adsadsda");</p><p> tmp.SetLabel("dsadsa", "asdasfds");</p><p> //tmp.Command = new MethodDelegateCommand(() => ChooseKeyAction(someString));</p><p> _items.Add(tmp);</p><p> _items.Add(new ListItem("cdgdfgdfgdfgdfg", "ddgdfgdfg"));</p><p> _items.FireChange();</p><p>}[/code]</p><p></p><p>The second Issue is that I get the following message:</p><p></p><p></p><p>The code:</p><p>[CODE=XML]<?xml version="1.0" encoding="utf-8"?></p><p><Include</p><p> xmlns="www.team-mediaportal.com/2008/mpf/directx"</p><p> xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"</p><p> Source="screens\master_menu.xaml"</p><p> ></p><p> <Include.Resources></p><p> <ControlTemplate x:Key="Contents_Template"></p><p> <Grid></p><p> <!-- Model = MediaNavigationModel --></p><p> <Grid.Resources></p><p> <Model x:Key="MediaModel" Id="CC11183C-01A9-4F96-AF90-FAA046981006"/></p><p> </Grid.Resources></p><p> <Grid.RowDefinitions></p><p> <RowDefinition Height="*"/></p><p> </Grid.RowDefinitions></p><p> <Grid.ColumnDefinitions></p><p> <ColumnDefinition Width="*"/></p><p> </Grid.ColumnDefinitions></p><p> <Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch" IsVisible="true"></p><p> <Grid.RowDefinitions></p><p> <RowDefinition Height="*"/></p><p> </Grid.RowDefinitions></p><p> <Grid.ColumnDefinitions></p><p> <ColumnDefinition Width="*"/></p><p> </Grid.ColumnDefinitions></p><p></p><p> <ListView Context="{Model Id=CC11183C-01A9-4F96-AF90-FAA046981006}" Style="{StaticResource ContentsMenuListViewStyle}" ItemsSource="{Binding Path=ActionItems,Mode=OneTime}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" IsVisible="true"></p><p> <ListView.Resources></p><p> <Command x:Key="Menu_Command" Source="{StaticResource MediaModel}" Path="Select"</p><p> Parameters="{LateBoundValue BindingValue={Binding}}"/></p><p> </ListView.Resources></p><p> </ListView></p><p> <Button Context="{Model Id=CC11183C-01A9-4F96-AF90-FAA046981006}" Content="Finish" Style="{ThemeResource ButtonWideStyle}" Margin="10"</p><p> HorizontalAlignment="Right" VerticalAlignment="Center"</p><p> Command="{Command AddKeyFinish}"/></p><p> </Grid></p><p> </Grid></p><p> </ControlTemplate></p><p> </Include.Resources></p><p></Include>[/CODE]</p><p></p><p>This is how I generate the items (you are probably screaming how I select the properties from "Key" <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite8" alt=":D" title="Big Grin :D" loading="lazy" data-shortname=":D" /></p><p>[CODE=C#]_actionItems = new ItemsList();</p><p> foreach (var property in typeof(Key).GetFields())</p><p> {</p><p> var listItem = new ListItem(property.Name, property.Name);</p><p> listItem.Command = new MethodDelegateCommand(() => ChooseKeyAction(property.Name));</p><p> _actionItems.Add(listItem);</p><p> ServiceRegistration.Get<ILogger>().Info("Action: {0}", property.Name);</p><p> }[/CODE]</p></blockquote><p></p>
[QUOTE="FreakyJ, post: 1153748, member: 106003"] [USER=48495]@morpheus_xx[/USER] I thought I would start working on a little Inputmanager, because this is requested by many people :) It is a bit how you doing, but anyway^^ First problem: I can add Items to the Listview and the Items shown, but without any text :( I tried to read in other plugins, but I think I did it exactly the same, but it just doesn't work :/ See attached Screenshot. The code looks liek this: [CODE=XML]<?xml version="1.0" encoding="utf-8"?> <Include xmlns="www.team-mediaportal.com/2008/mpf/directx" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Source="screens\master_menu.xaml" > <Include.Resources> <ControlTemplate x:Key="Contents_Template"> <Grid> <!-- Model = MediaNavigationModel --> <Grid.Resources> <Model x:Key="MediaModel" Id="CC11183C-01A9-4F96-AF90-FAA046981006"/> </Grid.Resources> <Grid.RowDefinitions> <RowDefinition Height="*"/> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition Width="*"/> </Grid.ColumnDefinitions> <Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch" IsVisible="true"> <Grid.RowDefinitions> <RowDefinition Height="*"/> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition Width="*"/> </Grid.ColumnDefinitions> <ListView Context="{Model Id=CC11183C-01A9-4F96-AF90-FAA046981006}" Style="{StaticResource ContentsMenuListViewStyle}" ItemsSource="{Binding Path=Items,Mode=OneTime}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" IsVisible="true"> <ListView.Resources> <!--<Command x:Key="Menu_Command" Source="{StaticResource MediaModel}" Path="Select" Parameters="{LateBoundValue BindingValue={Binding}}"/>--> <CommandBridge x:Key="Menu_Command" Command="{Binding Path=Command,Mode=OneTime}"/> </ListView.Resources> </ListView> <Button Context="{Model Id=CC11183C-01A9-4F96-AF90-FAA046981006}" Content="Add" Style="{ThemeResource ButtonWideStyle}" Margin="10" HorizontalAlignment="Right" VerticalAlignment="Center" Command="{Command AddKeyMapping}"/> </Grid> </Grid> </ControlTemplate> </Include.Resources> </Include>[/CODE] And the creation of the ListItems: [code]protected ItemsList _items; public ItemsList Items { get { return _items; } } private void InitModel() { _items = new ItemsList(); [....] var tmp = new ListItem(); tmp.SetLabel("asdda", "sadas"); tmp.SetLabel("dsfsdf", "adsadsda"); tmp.SetLabel("dsadsa", "asdasfds"); //tmp.Command = new MethodDelegateCommand(() => ChooseKeyAction(someString)); _items.Add(tmp); _items.Add(new ListItem("cdgdfgdfgdfgdfg", "ddgdfgdfg")); _items.FireChange(); }[/code] The second Issue is that I get the following message: The code: [CODE=XML]<?xml version="1.0" encoding="utf-8"?> <Include xmlns="www.team-mediaportal.com/2008/mpf/directx" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Source="screens\master_menu.xaml" > <Include.Resources> <ControlTemplate x:Key="Contents_Template"> <Grid> <!-- Model = MediaNavigationModel --> <Grid.Resources> <Model x:Key="MediaModel" Id="CC11183C-01A9-4F96-AF90-FAA046981006"/> </Grid.Resources> <Grid.RowDefinitions> <RowDefinition Height="*"/> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition Width="*"/> </Grid.ColumnDefinitions> <Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch" IsVisible="true"> <Grid.RowDefinitions> <RowDefinition Height="*"/> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition Width="*"/> </Grid.ColumnDefinitions> <ListView Context="{Model Id=CC11183C-01A9-4F96-AF90-FAA046981006}" Style="{StaticResource ContentsMenuListViewStyle}" ItemsSource="{Binding Path=ActionItems,Mode=OneTime}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" IsVisible="true"> <ListView.Resources> <Command x:Key="Menu_Command" Source="{StaticResource MediaModel}" Path="Select" Parameters="{LateBoundValue BindingValue={Binding}}"/> </ListView.Resources> </ListView> <Button Context="{Model Id=CC11183C-01A9-4F96-AF90-FAA046981006}" Content="Finish" Style="{ThemeResource ButtonWideStyle}" Margin="10" HorizontalAlignment="Right" VerticalAlignment="Center" Command="{Command AddKeyFinish}"/> </Grid> </Grid> </ControlTemplate> </Include.Resources> </Include>[/CODE] This is how I generate the items (you are probably screaming how I select the properties from "Key" :D [CODE=C#]_actionItems = new ItemsList(); foreach (var property in typeof(Key).GetFields()) { var listItem = new ListItem(property.Name, property.Name); listItem.Command = new MethodDelegateCommand(() => ChooseKeyAction(property.Name)); _actionItems.Add(listItem); ServiceRegistration.Get<ILogger>().Info("Action: {0}", property.Name); }[/CODE] [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
MediaPortal 2
Plugin Development
ListView command binding and Item labels
Contact us
RSS
Top
Bottom