Binding Properties not updating (1 Viewer)

sccrgoalie1

Portal Pro
September 12, 2013
109
165
34
United States of America United States of America
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>
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; }
    }
  }
}
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();    
}
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

OP Similar threads Forum Replies Date
B [Finished] [MP2-817] Implement NotifyOnSourceUpdated and NotifyOnTargetUpdated binding events MediaPortal 2 3
Rob Hexenmeister Mediaportal Properties #plot etc... General Support 3
Rob Hexenmeister Latest Media Handler - facade properties - itemcount General Support 3
ajs [solved] New property in VideoArtistInfo page MediaPortal 1 24
zunixnuz Missing #iswatched property to recorded TV Titan Skin Feedback 5
G Update von MediaPortal Installationsprobleme? 0
morpheus_xx [Evaluate] Update to VS 2019? MediaPortal 2 4
Golf4 Nach Windows-Updates läuft TV-Plugin nicht mehr Allgemeines Support- und Diskussionsforum 0
B MPEM update list never completes. General Support 0
JJDoherty Updated DTT frequencies for Ireland... Submit: EPG-Grabbers and tuningdetails 1
Dark Eyes Updated to Windows 10, now TVServer won't work Installation, configuration support 1
R [solved] Files moved to new location - Easy way to update database? My TVSeries 7
M.Hulot Moving Pictures lässt sich nach Windows-Update nicht mehr öffnen Plugins & Erweiterungen 1
R Files moved to different location - Easy way to update database? Moving Pictures 2
k12158 [solved] Kein direkter Wechsel von TV-Kanal zu TV-Kanal mehr nach Update? Allgemeines Support- und Diskussionsforum 16
ajs Mediaportal update to .Net 4.6.2+ MediaPortal 1 13
Mr6686 [solved] Titan skin broken since update to 1.23 Installation, configuration support 6
B TV-Server Auto-Update mptvdb after x hours General Support 0
Terra LAVFilter Plugin cannot be updated (MP1.23) MediaPortal 1 Plugins 10
TLD Windows 10 1903 feature update General Support 3
azzuro [Pending] Update MP1 to VisualStudio 2019 MediaPortal 1 36
A Problem Windows 10 64 bit prof. Update auf Version 1903(gelöst) Installationsprobleme? 0
T No TV after updating Windows 10 to latest Version 1903 / OS build 18362.175 (logs attached) General Support 2
M [solved] Updated Swedish translation for MP 1.24 Submit: Localization of MediaPortal and DeployTool 0
framug 1.22.0 BasicHome Editor settings for DefaultWide HD skin not kept when update 1.22 3
Similar threads

























Top Bottom