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
Binding Properties not updating
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="sccrgoalie1" data-source="post: 1037561" data-attributes="member: 143879"><p>I wasn't able to make HeaderedItemsControl work properly, but have solved my issue. I suspect the problem with the HeaderedItemsControl is getting a proper Style built. I'm going to post my working code below in case others come looking and have a similar problem with binding. Specfically what this style lets you do is place items on the screen using X, Y coordinates which is what I need for my plugin.</p><p></p><p>XAML</p><p>[CODE]<Screen xmlns="www.team-mediaportal.com/2008/mpf/directx"</p><p> xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"</p><p> xmlns:collections="clr-namespace:MediaPortal.UI.Presentation.DataObjects;assembly=MediaPortal.UI"</p><p> Context="{Model Id=C6B0FA5A-288E-405A-A5D5-AA66CC0AA327}"></p><p> <Screen.Resources></p><p> <DataTemplate x:Key="ItemDataTemplate" DataType="{x:Type collections:ListItem}"></p><p> <Canvas></p><p> <Grid Canvas.Left="{Binding LeftProperty}" Canvas.Top="{Binding TopProperty}"></p><p> <Border x:Name="PictureBorder" MaxWidth="{Binding Path=PictureWidthProperty}"</p><p> MaxHeight="{Binding Path=PictureHeightProperty}"</p><p> HorizontalAlignment="Left" VerticalAlignment="Top" ></p><p> <Border.Background></p><p> <ImageBrush ImageSource="{Binding Path=BorderImageProperty}" Tile="Tile"/></p><p> </Border.Background></p><p> <Image Source ="{Binding Path=PictureImageProperty}" Stretch="Uniform" Margin ="{Binding Path=PictureBorderMarginsProperty}"/></p><p> </Border></p><p> <Label x:Name="PictureLabel" Content="{Binding Path=PictureDateProperty}"</p><p> HorizontalAlignment="Center" VerticalAlignment="Bottom"</p><p> Color="{Binding Path=PictureDateColorProperty}" FontSize="8"/></p><p> </Grid></p><p> </Canvas></p><p> </DataTemplate></p><p> <Style x:Key="ListViewStyle" BasedOn="{ThemeResource DefaultListViewStyle}"></p><p> <Setter Property="Template"></p><p> <Setter.Value></p><p> <ControlTemplate TargetType="{x:Type ListView}"></p><p> <ItemsPresenter VerticalAlignment="Stretch" HorizontalAlignment="Stretch"/> </p><p> </ControlTemplate></p><p> </Setter.Value></p><p> </Setter></p><p> <Setter Property="ItemTemplate" Value="{ThemeResource ItemDataTemplate}"/></p><p> <Setter Property="ItemsPanel"></p><p> <Setter.Value></p><p> <ItemsPanelTemplate></p><p> <Grid x:Name="ListItemsHost" IsItemsHost="True"/></p><p> </ItemsPanelTemplate></p><p> </Setter.Value></p><p> </Setter></p><p> </Style></p><p> </Screen.Resources> </p><p> <Canvas></p><p> <Canvas.Background></p><p> <ImageBrush ImageSource="{Binding Path=SlideshowBackgroundProperty}" Stretch="Fill"/></p><p> </Canvas.Background></p><p> <ListView Style="{ThemeResource ListViewStyle}" ItemsSource="{Binding Path=PictureList}"/> </p><p> </Canvas></p><p></Screen>[/CODE]</p><p></p><p>BindingPicture class</p><p>[CODE]using MediaPortal.Common.General;</p><p>using MediaPortal.UI.Presentation.DataObjects;</p><p>using System;</p><p>using System.Linq;</p><p>using System.Text;</p><p></p><p>namespace MPPhotoSlideshow</p><p>{</p><p> public class BindingPicture : ListItem</p><p> {</p><p> protected readonly AbstractProperty _left = new WProperty(typeof(int), 0);</p><p> protected readonly AbstractProperty _top = new WProperty(typeof(int), 0);</p><p> protected readonly AbstractProperty _pictureImage = new WProperty(typeof(string), string.Empty);</p><p> protected readonly AbstractProperty _pictureWidth = new WProperty(typeof(int), 0);</p><p> protected readonly AbstractProperty _pictureHeight = new WProperty(typeof(int), 0);</p><p> protected readonly AbstractProperty _borderImage = new WProperty(typeof(string), string.Empty);</p><p> protected readonly AbstractProperty _pictureBorderMargins = new WProperty(typeof(string), string.Empty);</p><p> protected readonly AbstractProperty _pictureDate = new WProperty(typeof(string), string.Empty);</p><p> protected readonly AbstractProperty _pictureDateColor = new WProperty(typeof(string), string.Empty);</p><p></p><p> // Public properties</p><p> public int Left</p><p> {</p><p> get { return (int)_left.GetValue(); }</p><p> set { _left.SetValue(value); }</p><p> }</p><p> public int Top</p><p> {</p><p> get { return (int)_top.GetValue(); }</p><p> set { _top.SetValue(value); }</p><p> }</p><p> public int PictureWidth</p><p> {</p><p> get { return (int)_pictureWidth.GetValue(); }</p><p> set { _pictureWidth.SetValue(value); }</p><p> }</p><p> public int PictureHeight</p><p> {</p><p> get { return (int)_pictureHeight.GetValue(); }</p><p> set { _pictureHeight.SetValue(value); }</p><p> }</p><p> public string BorderImage</p><p> {</p><p> get { return (string)_borderImage.GetValue(); }</p><p> set { _borderImage.SetValue(value); }</p><p> }</p><p> public string PictureBorderMargins</p><p> {</p><p> get { return (string)_pictureBorderMargins.GetValue(); }</p><p> set { _pictureBorderMargins.SetValue(value); }</p><p> }</p><p> public string PictureDate</p><p> {</p><p> get { return (string)_pictureDate.GetValue(); }</p><p> set { _pictureDate.SetValue(value); }</p><p> }</p><p> public string PictureDateColor</p><p> {</p><p> get { return (string)_pictureDateColor.GetValue(); }</p><p> set { _pictureDateColor.SetValue(value); }</p><p> }</p><p> public string PictureImage</p><p> {</p><p> get { return (string)_pictureImage.GetValue(); }</p><p> set { _pictureImage.SetValue(value); }</p><p> }</p><p> public AbstractProperty PictureWidthProperty</p><p> {</p><p> get { return _pictureWidth; }</p><p> }</p><p> public AbstractProperty PictureHeightProperty</p><p> {</p><p> get { return _pictureHeight; }</p><p> }</p><p> public AbstractProperty BorderImageProperty</p><p> {</p><p> get { return _borderImage; }</p><p> }</p><p> public AbstractProperty PictureBorderMarginsProperty</p><p> {</p><p> get { return _pictureBorderMargins; }</p><p> }</p><p> public AbstractProperty PictureDateProperty</p><p> {</p><p> get { return _pictureDate; }</p><p> }</p><p> public AbstractProperty PictureDateColorProperty</p><p> {</p><p> get { return _pictureDateColor; }</p><p> }</p><p> public AbstractProperty PictureImageProperty</p><p> {</p><p> get { return _pictureImage; }</p><p> }</p><p></p><p> public AbstractProperty TopProperty</p><p> {</p><p> get { return _top; }</p><p> }</p><p></p><p> public AbstractProperty LeftProperty</p><p> {</p><p> get { return _left; }</p><p> }</p><p> }</p><p>}</p><p>[/CODE]</p><p></p><p>Model</p><p>[CODE] </p><p>protected readonly ItemsList _pictureList = new ItemsList(); </p><p> /// <summary></p><p> /// Exposes the picture list to the skin</p><p> /// </summary></p><p> public ItemsList PictureList</p><p> {</p><p> get { return _pictureList; }</p><p> }</p><p>private void LoadPage()</p><p>{</p><p>PictureList.Clear();</p><p> PhotoTemplate template = _photoTemplates[_templateRnd.Next(_photoTemplates.Count)];</p><p> for (int i = 0; i < template.Photos.Count; i++)</p><p> {</p><p> if (template.Photos[i].Enabled)</p><p> {</p><p> Picture pictureFileName = GetPicture(template, i);</p><p> Log.Debug(pictureFileName.FilePath);</p><p> Size ImageMargin = ScaleToScreen(template.Photos[i].Image.posY, template.Photos[i].Image.posX);</p><p> Size ImageSize = ScaleToScreen(template.Photos[i].Image.Height, template.Photos[i].Image.Width);</p><p> PictureList.Add(new BindingPicture()</p><p> {</p><p> BorderImage = template.Photos[i].Image.BorderPath,</p><p> PictureBorderMargins = String.Format("{0},{1},{2},{3}", template.Photos[i].Image.BorderLeft, template.Photos[i].Image.BorderTop, template.Photos[i].Image.BorderRight, template.Photos[i].Image.BorderBottom),</p><p> Left = Convert.ToInt32(ImageMargin.Width),</p><p> Top = Convert.ToInt32(ImageMargin.Height),</p><p> PictureDate = pictureFileName.DateTaken.ToString("d"),</p><p> PictureDateColor = template.Photos[i].Label.TextColor,</p><p> PictureHeight = Convert.ToInt32(ImageSize.Height),</p><p> PictureWidth = Convert.ToInt32(ImageSize.Width),</p><p> PictureImage = pictureFileName.FilePath,</p><p> });</p><p> }</p><p> }</p><p> Log.Debug("Firing picture list changed with count of {0}", PictureList.Count);</p><p> PictureList.FireChange(); </p><p>}[/CODE]</p></blockquote><p></p>
[QUOTE="sccrgoalie1, post: 1037561, member: 143879"] I wasn't able to make HeaderedItemsControl work properly, but have solved my issue. I suspect the problem with the HeaderedItemsControl is getting a proper Style built. I'm going to post my working code below in case others come looking and have a similar problem with binding. Specfically what this style lets you do is place items on the screen using X, Y coordinates which is what I need for my plugin. XAML [CODE]<Screen xmlns="www.team-mediaportal.com/2008/mpf/directx" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:collections="clr-namespace:MediaPortal.UI.Presentation.DataObjects;assembly=MediaPortal.UI" Context="{Model Id=C6B0FA5A-288E-405A-A5D5-AA66CC0AA327}"> <Screen.Resources> <DataTemplate x:Key="ItemDataTemplate" DataType="{x:Type collections:ListItem}"> <Canvas> <Grid Canvas.Left="{Binding LeftProperty}" Canvas.Top="{Binding TopProperty}"> <Border x:Name="PictureBorder" MaxWidth="{Binding Path=PictureWidthProperty}" MaxHeight="{Binding Path=PictureHeightProperty}" HorizontalAlignment="Left" VerticalAlignment="Top" > <Border.Background> <ImageBrush ImageSource="{Binding Path=BorderImageProperty}" Tile="Tile"/> </Border.Background> <Image Source ="{Binding Path=PictureImageProperty}" Stretch="Uniform" Margin ="{Binding Path=PictureBorderMarginsProperty}"/> </Border> <Label x:Name="PictureLabel" Content="{Binding Path=PictureDateProperty}" HorizontalAlignment="Center" VerticalAlignment="Bottom" Color="{Binding Path=PictureDateColorProperty}" FontSize="8"/> </Grid> </Canvas> </DataTemplate> <Style x:Key="ListViewStyle" BasedOn="{ThemeResource DefaultListViewStyle}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type ListView}"> <ItemsPresenter VerticalAlignment="Stretch" HorizontalAlignment="Stretch"/> </ControlTemplate> </Setter.Value> </Setter> <Setter Property="ItemTemplate" Value="{ThemeResource ItemDataTemplate}"/> <Setter Property="ItemsPanel"> <Setter.Value> <ItemsPanelTemplate> <Grid x:Name="ListItemsHost" IsItemsHost="True"/> </ItemsPanelTemplate> </Setter.Value> </Setter> </Style> </Screen.Resources> <Canvas> <Canvas.Background> <ImageBrush ImageSource="{Binding Path=SlideshowBackgroundProperty}" Stretch="Fill"/> </Canvas.Background> <ListView Style="{ThemeResource ListViewStyle}" ItemsSource="{Binding Path=PictureList}"/> </Canvas> </Screen>[/CODE] BindingPicture class [CODE]using MediaPortal.Common.General; using MediaPortal.UI.Presentation.DataObjects; using System; using System.Linq; using System.Text; namespace MPPhotoSlideshow { public class BindingPicture : ListItem { protected readonly AbstractProperty _left = new WProperty(typeof(int), 0); protected readonly AbstractProperty _top = new WProperty(typeof(int), 0); protected readonly AbstractProperty _pictureImage = new WProperty(typeof(string), string.Empty); protected readonly AbstractProperty _pictureWidth = new WProperty(typeof(int), 0); protected readonly AbstractProperty _pictureHeight = new WProperty(typeof(int), 0); protected readonly AbstractProperty _borderImage = new WProperty(typeof(string), string.Empty); protected readonly AbstractProperty _pictureBorderMargins = new WProperty(typeof(string), string.Empty); protected readonly AbstractProperty _pictureDate = new WProperty(typeof(string), string.Empty); protected readonly AbstractProperty _pictureDateColor = new WProperty(typeof(string), string.Empty); // Public properties public int Left { get { return (int)_left.GetValue(); } set { _left.SetValue(value); } } public int Top { get { return (int)_top.GetValue(); } set { _top.SetValue(value); } } public int PictureWidth { get { return (int)_pictureWidth.GetValue(); } set { _pictureWidth.SetValue(value); } } public int PictureHeight { get { return (int)_pictureHeight.GetValue(); } set { _pictureHeight.SetValue(value); } } public string BorderImage { get { return (string)_borderImage.GetValue(); } set { _borderImage.SetValue(value); } } public string PictureBorderMargins { get { return (string)_pictureBorderMargins.GetValue(); } set { _pictureBorderMargins.SetValue(value); } } public string PictureDate { get { return (string)_pictureDate.GetValue(); } set { _pictureDate.SetValue(value); } } public string PictureDateColor { get { return (string)_pictureDateColor.GetValue(); } set { _pictureDateColor.SetValue(value); } } public string PictureImage { get { return (string)_pictureImage.GetValue(); } set { _pictureImage.SetValue(value); } } public AbstractProperty PictureWidthProperty { get { return _pictureWidth; } } public AbstractProperty PictureHeightProperty { get { return _pictureHeight; } } public AbstractProperty BorderImageProperty { get { return _borderImage; } } public AbstractProperty PictureBorderMarginsProperty { get { return _pictureBorderMargins; } } public AbstractProperty PictureDateProperty { get { return _pictureDate; } } public AbstractProperty PictureDateColorProperty { get { return _pictureDateColor; } } public AbstractProperty PictureImageProperty { get { return _pictureImage; } } public AbstractProperty TopProperty { get { return _top; } } public AbstractProperty LeftProperty { get { return _left; } } } } [/CODE] Model [CODE] protected readonly ItemsList _pictureList = new ItemsList(); /// <summary> /// Exposes the picture list to the skin /// </summary> public ItemsList PictureList { get { return _pictureList; } } private void LoadPage() { PictureList.Clear(); PhotoTemplate template = _photoTemplates[_templateRnd.Next(_photoTemplates.Count)]; for (int i = 0; i < template.Photos.Count; i++) { if (template.Photos[i].Enabled) { Picture pictureFileName = GetPicture(template, i); Log.Debug(pictureFileName.FilePath); Size ImageMargin = ScaleToScreen(template.Photos[i].Image.posY, template.Photos[i].Image.posX); Size ImageSize = ScaleToScreen(template.Photos[i].Image.Height, template.Photos[i].Image.Width); PictureList.Add(new BindingPicture() { BorderImage = template.Photos[i].Image.BorderPath, PictureBorderMargins = String.Format("{0},{1},{2},{3}", template.Photos[i].Image.BorderLeft, template.Photos[i].Image.BorderTop, template.Photos[i].Image.BorderRight, template.Photos[i].Image.BorderBottom), Left = Convert.ToInt32(ImageMargin.Width), Top = Convert.ToInt32(ImageMargin.Height), PictureDate = pictureFileName.DateTaken.ToString("d"), PictureDateColor = template.Photos[i].Label.TextColor, PictureHeight = Convert.ToInt32(ImageSize.Height), PictureWidth = Convert.ToInt32(ImageSize.Width), PictureImage = pictureFileName.FilePath, }); } } Log.Debug("Firing picture list changed with count of {0}", PictureList.Count); PictureList.FireChange(); }[/CODE] [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
MediaPortal 2
Plugin Development
Binding Properties not updating
Contact us
RSS
Top
Bottom