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: 1036888" data-attributes="member: 143879"><p>Some more binding issues, I'm attempting to improve my plugin by using an ItemsControl instead of explicitly adding each item in XAML. I've tested the code below in Blend and it works, so I'm pretty sure my binding is the issue. I've been trying to get this working for about a week, so any help would be appreciated. I've been trying use the weather model as my source. Also, I did add the ObservableCollection to MP2 as shown in this branch <a href="https://github.com/MediaPortal/MediaPortal-2/tree/FEAT_ObservableCollections" target="_blank">https://github.com/MediaPortal/MediaPortal-2/tree/FEAT_ObservableCollections</a></p><p></p><p>Here's the code:</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> Context="{Model Id=C6B0FA5A-288E-405A-A5D5-AA66CC0AA327}"></p><p> <Screen.Resources></p><p> <Model x:Key="Model" Id="C6B0FA5A-288E-405A-A5D5-AA66CC0AA327"/></p><p> </Screen.Resources></p><p> <Canvas DataContext="{Binding Source={StaticResource Model}}"></p><p> <Canvas.Background></p><p> <ImageBrush ImageSource="{Binding Path=SlideshowBackgroundProperty}" Stretch="Fill"/></p><p> </Canvas.Background></p><p> <HeaderedItemsControl ItemsSource="{Binding Path=PictureList}"></p><p> <HeaderedItemsControl.ItemsPanel></p><p> <ItemsPanelTemplate></p><p> <Canvas Background="Green"/></p><p> </ItemsPanelTemplate></p><p> </HeaderedItemsControl.ItemsPanel></p><p> <HeaderedItemsControl.ItemContainerStyle></p><p> <Style TargetType="ContentPresenter"></p><p> <Setter Property="Canvas.Left" Value="{Binding Path=Left}"/></p><p> <Setter Property="Canvas.Top" Value="{Binding Path=Top}"/></p><p> </Style></p><p> </HeaderedItemsControl.ItemContainerStyle></p><p> <HeaderedItemsControl.ItemTemplate></p><p> <DataTemplate></p><p> <Image Source ="{Binding Path=PictureImage}" Stretch="Uniform" MaxWidth="50" MaxHeight="50"/></p><p> </DataTemplate></p><p> </HeaderedItemsControl.ItemTemplate></p><p> </HeaderedItemsControl> </p><p> </Canvas></p><p></Screen>[/CODE]</p><p></p><p>Binding Picture</p><p>[CODE]using System;</p><p>using System.Collections.Generic;</p><p>using System.ComponentModel;</p><p>using System.Linq;</p><p>using System.Text;</p><p></p><p>namespace MPPhotoSlideshow</p><p>{</p><p> public class BindingPicture:INotifyPropertyChanged</p><p> {</p><p> public event PropertyChangedEventHandler PropertyChanged;</p><p> private void NotifyPropertyChanged(string propertyName)</p><p> {</p><p> if (PropertyChanged != null)</p><p> {</p><p> PropertyChanged(this, new PropertyChangedEventArgs(propertyName));</p><p> }</p><p> }</p><p> private int _left;</p><p> public int Left</p><p> {</p><p> get { return _left; }</p><p> set</p><p> {</p><p> if (_left != value)</p><p> _left = value;</p><p> NotifyPropertyChanged("Left");</p><p> }</p><p> }</p><p> private int _top;</p><p> public int Top</p><p> {</p><p> get { return _top; }</p><p> set</p><p> {</p><p> if (_top != value)</p><p> _top = value;</p><p> NotifyPropertyChanged("Top");</p><p> }</p><p> }</p><p> private string _pictureImage;</p><p> public string PictureImage</p><p> {</p><p> get { return _pictureImage; }</p><p> set</p><p> {</p><p> if (_pictureImage != value)</p><p> _pictureImage = value;</p><p> NotifyPropertyChanged("PictureImage");</p><p> }</p><p> }</p><p>}[/CODE]</p><p></p><p>Model</p><p></p><p>[CODE]</p><p>protected readonly AbstractProperty _slideshowBackgroundProperty;</p><p>private ObservableCollection<BindingPicture> _pictureList = null;</p><p>public ObservableCollection<BindingPicture> PictureList;</p><p>public string SlideshowBackground</p><p> {</p><p> get { return (string)_slideshowBackgroundProperty.GetValue(); }</p><p> set { _slideshowBackgroundProperty.SetValue(value); }</p><p> }</p><p>public AbstractProperty SlideshowBackgroundProperty</p><p> {</p><p> get { return _slideshowBackgroundProperty; }</p><p> }</p><p>public MPPhotoSlideshowModel()</p><p> {</p><p> try</p><p> {</p><p>_slideshowBackgroundProperty = new WProperty(typeof(object), null);</p><p>settings = new XMLSettings(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + @"\MPPhotoSlideshow\", "MPPhotoSlideshow2.xml");</p><p> SlideshowBackground= settings.getXmlAttribute("BackgroundPath");</p><p> _pictureList= new ObservableCollection<BindingPicture>();</p><p> _pictureList.Add(new BindingPicture() { Left=10, Top=10, PictureImage=@"C:\Users\Mark\Pictures\Tulips.jpg"});</p><p> PictureList.FireChange();</p><p>}</p><p>}</p><p>[/CODE]</p></blockquote><p></p>
[QUOTE="sccrgoalie1, post: 1036888, member: 143879"] Some more binding issues, I'm attempting to improve my plugin by using an ItemsControl instead of explicitly adding each item in XAML. I've tested the code below in Blend and it works, so I'm pretty sure my binding is the issue. I've been trying to get this working for about a week, so any help would be appreciated. I've been trying use the weather model as my source. Also, I did add the ObservableCollection to MP2 as shown in this branch [url]https://github.com/MediaPortal/MediaPortal-2/tree/FEAT_ObservableCollections[/url] Here's the code: xaml [CODE]<Screen xmlns="www.team-mediaportal.com/2008/mpf/directx" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Context="{Model Id=C6B0FA5A-288E-405A-A5D5-AA66CC0AA327}"> <Screen.Resources> <Model x:Key="Model" Id="C6B0FA5A-288E-405A-A5D5-AA66CC0AA327"/> </Screen.Resources> <Canvas DataContext="{Binding Source={StaticResource Model}}"> <Canvas.Background> <ImageBrush ImageSource="{Binding Path=SlideshowBackgroundProperty}" Stretch="Fill"/> </Canvas.Background> <HeaderedItemsControl ItemsSource="{Binding Path=PictureList}"> <HeaderedItemsControl.ItemsPanel> <ItemsPanelTemplate> <Canvas Background="Green"/> </ItemsPanelTemplate> </HeaderedItemsControl.ItemsPanel> <HeaderedItemsControl.ItemContainerStyle> <Style TargetType="ContentPresenter"> <Setter Property="Canvas.Left" Value="{Binding Path=Left}"/> <Setter Property="Canvas.Top" Value="{Binding Path=Top}"/> </Style> </HeaderedItemsControl.ItemContainerStyle> <HeaderedItemsControl.ItemTemplate> <DataTemplate> <Image Source ="{Binding Path=PictureImage}" Stretch="Uniform" MaxWidth="50" MaxHeight="50"/> </DataTemplate> </HeaderedItemsControl.ItemTemplate> </HeaderedItemsControl> </Canvas> </Screen>[/CODE] Binding Picture [CODE]using System; using System.Collections.Generic; using System.ComponentModel; using System.Linq; using System.Text; namespace MPPhotoSlideshow { public class BindingPicture:INotifyPropertyChanged { public event PropertyChangedEventHandler PropertyChanged; private void NotifyPropertyChanged(string propertyName) { if (PropertyChanged != null) { PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); } } private int _left; public int Left { get { return _left; } set { if (_left != value) _left = value; NotifyPropertyChanged("Left"); } } private int _top; public int Top { get { return _top; } set { if (_top != value) _top = value; NotifyPropertyChanged("Top"); } } private string _pictureImage; public string PictureImage { get { return _pictureImage; } set { if (_pictureImage != value) _pictureImage = value; NotifyPropertyChanged("PictureImage"); } } }[/CODE] Model [CODE] protected readonly AbstractProperty _slideshowBackgroundProperty; private ObservableCollection<BindingPicture> _pictureList = null; public ObservableCollection<BindingPicture> PictureList; public string SlideshowBackground { get { return (string)_slideshowBackgroundProperty.GetValue(); } set { _slideshowBackgroundProperty.SetValue(value); } } public AbstractProperty SlideshowBackgroundProperty { get { return _slideshowBackgroundProperty; } } public MPPhotoSlideshowModel() { try { _slideshowBackgroundProperty = new WProperty(typeof(object), null); settings = new XMLSettings(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + @"\MPPhotoSlideshow\", "MPPhotoSlideshow2.xml"); SlideshowBackground= settings.getXmlAttribute("BackgroundPath"); _pictureList= new ObservableCollection<BindingPicture>(); _pictureList.Add(new BindingPicture() { Left=10, Top=10, PictureImage=@"C:\Users\Mark\Pictures\Tulips.jpg"}); PictureList.FireChange(); } } [/CODE] [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
MediaPortal 2
Plugin Development
Binding Properties not updating
Contact us
RSS
Top
Bottom