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: 1031145" data-attributes="member: 143879"><p>Hello,</p><p></p><p>I'm slowly learning the new MP2 development and I'm having an issue with Binding that I can figure out. I know my model is bound correctly because when I set the property on first load it works just fine. The problem is when I try to update that property later nothing happens. Here's the relevant code:</p><p></p><p>XAML</p><p>[CODE=xml] <Grid x:Name="Picture1Grid" Margin="{Binding Path=Picture1GridMargin}"></p><p> <Grid.RenderTransform></p><p> <TransformGroup></p><p> <RotateTransform CenterX="100" CenterY="75" Angle="0" /></p><p> <ScaleTransform ScaleX="1" ScaleY="1"/></p><p> </TransformGroup></p><p> </Grid.RenderTransform></p><p> <Border x:Name="Picture1Border" BorderBrush="White"</p><p> BorderThickness="10" MaxWidth="{Binding Path=Picture1Width}"</p><p> MaxHeight="{Binding Path=Picture1Height}"</p><p> HorizontalAlignment="Left" VerticalAlignment="Top" ></p><p> <Image Source ="{Binding Path=Picture1}" Stretch="Uniform"/></p><p> </Border></p><p> <Label x:Name="Picture1Label" Content="{Binding Path=Picture1Date}"</p><p> HorizontalAlignment="Center" VerticalAlignment="Bottom"</p><p> Color="{Binding Path=Picture1DateColor}" FontSize="8"/></p><p> </Grid>[/CODE]</p><p></p><p>CS</p><p>[CODE=csharp]</p><p>protected readonly AbstractProperty _picture1Property;</p><p> protected readonly AbstractProperty _picture1GridMargin;</p><p> protected readonly AbstractProperty _picture1Date;</p><p> protected readonly AbstractProperty _picture1DateColor;</p><p> protected readonly AbstractProperty _picture1Width;</p><p> protected readonly AbstractProperty _picture1Height;</p><p></p><p>public MPPhotoSlideshowModel()</p><p> {</p><p> try</p><p> {</p><p> // In models, properties will always be WProperty instances. When using SProperties for screen databinding,</p><p> // the system might run into memory leaks.</p><p> log = new Log(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + @"\Team MediaPortal\MP2-Client\Log", "MPPhotoSlideshow", "log", LogType.Debug);</p><p> _helloStringProperty = new WProperty(typeof(string), HELLOWORLD_RESOURCE);</p><p> _picture1Property = new WProperty(typeof(object), null);</p><p> _picture1Date = new WProperty(typeof(string), null);</p><p> _picture1GridMargin = new WProperty(typeof(object), null);</p><p> _picture1DateColor = new WProperty(typeof(object), null);</p><p> _picture1Width = new WProperty(typeof(object), null);</p><p> _picture1Height = new WProperty(typeof(object), null);</p><p> LoadSettings();</p><p> LoadPage();</p><p> }</p><p> catch (Exception ex)</p><p> {</p><p> if (log != null)</p><p> {</p><p> log.writeLog(ex.ToString(), LogInfoType.Error);</p><p> }</p><p> }</p><p> }</p><p></p><p>public string Picture1Date</p><p> {</p><p> get { return (string)_picture1Date.GetValue(); }</p><p> set { _picture1Date.SetValue(value); }</p><p> }</p><p> public object Picture1</p><p> {</p><p> get { return (object)_picture1Property.GetValue(); }</p><p> set { _picture1Property.SetValue(value); }</p><p> }</p><p> public object Picture1GridMargin</p><p> {</p><p> get { return (object)_picture1GridMargin.GetValue(); }</p><p> set { _picture1GridMargin.SetValue(value); }</p><p> }</p><p> public object Picture1DateColor</p><p> {</p><p> get { return (object)_picture1DateColor.GetValue(); }</p><p> set { _picture1DateColor.SetValue(value); }</p><p> }</p><p> public object Picture1Height</p><p> {</p><p> get { return (object)_picture1Height.GetValue(); }</p><p> set { _picture1Height.SetValue(value); }</p><p> }</p><p> public object Picture1Width</p><p> {</p><p> get { return (object)_picture1Width.GetValue(); }</p><p> set { _picture1Width.SetValue(value); }</p><p> }</p><p>private void LoadPage()</p><p> {</p><p> try</p><p> {</p><p> PhotoTemplate template = _photoTemplates[_templateRnd.Next(_photoTemplates.Count)];</p><p> if (template.Photos[0].Enabled)</p><p> {</p><p> Picture picture1FileName;</p><p> if (template.Photos[0].Image.Height > template.Photos[0].Image.Width)</p><p> {</p><p> picture1FileName = _verticalPictures[_verticalRnd.Next(_verticalPictures.Count)];</p><p> }</p><p> else</p><p> {</p><p> picture1FileName = _horizontalPictures[_horizontalRnd.Next(_horizontalPictures.Count)];</p><p> }</p><p> //log.writeLog(String.Format("MPSlideshow.LoadPage() - Setting new file name {0}",picture1FileName.FilePath), LogInfoType.Debug);</p><p> Picture1 = picture1FileName.FilePath;</p><p> Picture1GridMargin = String.Format("{0},{1},{2},{3}", template.Photos[0].Image.posX, template.Photos[0].Image.posY, 0, 0);</p><p> Picture1Date = picture1FileName.DateTaken.ToString("d");</p><p> Picture1DateColor = template.Photos[0].Label.TextColor;</p><p> Picture1Width = template.Photos[0].Image.Width;</p><p> Picture1Height = template.Photos[0].Image.Height;</p><p> }</p><p> }</p><p> catch (Exception ex)</p><p> {</p><p> log.writeLog(ex.ToString(), LogInfoType.Error);</p><p> }</p><p> }[/CODE]</p><p></p><p>Any idea why this isn't updating. The LoadPage() method is called every 10 seconds via a timer tick event.</p></blockquote><p></p>
[QUOTE="sccrgoalie1, post: 1031145, member: 143879"] Hello, I'm slowly learning the new MP2 development and I'm having an issue with Binding that I can figure out. I know my model is bound correctly because when I set the property on first load it works just fine. The problem is when I try to update that property later nothing happens. Here's the relevant code: XAML [CODE=xml] <Grid x:Name="Picture1Grid" Margin="{Binding Path=Picture1GridMargin}"> <Grid.RenderTransform> <TransformGroup> <RotateTransform CenterX="100" CenterY="75" Angle="0" /> <ScaleTransform ScaleX="1" ScaleY="1"/> </TransformGroup> </Grid.RenderTransform> <Border x:Name="Picture1Border" BorderBrush="White" BorderThickness="10" MaxWidth="{Binding Path=Picture1Width}" MaxHeight="{Binding Path=Picture1Height}" HorizontalAlignment="Left" VerticalAlignment="Top" > <Image Source ="{Binding Path=Picture1}" Stretch="Uniform"/> </Border> <Label x:Name="Picture1Label" Content="{Binding Path=Picture1Date}" HorizontalAlignment="Center" VerticalAlignment="Bottom" Color="{Binding Path=Picture1DateColor}" FontSize="8"/> </Grid>[/CODE] CS [CODE=csharp] protected readonly AbstractProperty _picture1Property; protected readonly AbstractProperty _picture1GridMargin; protected readonly AbstractProperty _picture1Date; protected readonly AbstractProperty _picture1DateColor; protected readonly AbstractProperty _picture1Width; protected readonly AbstractProperty _picture1Height; public MPPhotoSlideshowModel() { try { // In models, properties will always be WProperty instances. When using SProperties for screen databinding, // the system might run into memory leaks. log = new Log(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + @"\Team MediaPortal\MP2-Client\Log", "MPPhotoSlideshow", "log", LogType.Debug); _helloStringProperty = new WProperty(typeof(string), HELLOWORLD_RESOURCE); _picture1Property = new WProperty(typeof(object), null); _picture1Date = new WProperty(typeof(string), null); _picture1GridMargin = new WProperty(typeof(object), null); _picture1DateColor = new WProperty(typeof(object), null); _picture1Width = new WProperty(typeof(object), null); _picture1Height = new WProperty(typeof(object), null); LoadSettings(); LoadPage(); } catch (Exception ex) { if (log != null) { log.writeLog(ex.ToString(), LogInfoType.Error); } } } public string Picture1Date { get { return (string)_picture1Date.GetValue(); } set { _picture1Date.SetValue(value); } } public object Picture1 { get { return (object)_picture1Property.GetValue(); } set { _picture1Property.SetValue(value); } } public object Picture1GridMargin { get { return (object)_picture1GridMargin.GetValue(); } set { _picture1GridMargin.SetValue(value); } } public object Picture1DateColor { get { return (object)_picture1DateColor.GetValue(); } set { _picture1DateColor.SetValue(value); } } public object Picture1Height { get { return (object)_picture1Height.GetValue(); } set { _picture1Height.SetValue(value); } } public object Picture1Width { get { return (object)_picture1Width.GetValue(); } set { _picture1Width.SetValue(value); } } private void LoadPage() { try { PhotoTemplate template = _photoTemplates[_templateRnd.Next(_photoTemplates.Count)]; if (template.Photos[0].Enabled) { Picture picture1FileName; if (template.Photos[0].Image.Height > template.Photos[0].Image.Width) { picture1FileName = _verticalPictures[_verticalRnd.Next(_verticalPictures.Count)]; } else { picture1FileName = _horizontalPictures[_horizontalRnd.Next(_horizontalPictures.Count)]; } //log.writeLog(String.Format("MPSlideshow.LoadPage() - Setting new file name {0}",picture1FileName.FilePath), LogInfoType.Debug); Picture1 = picture1FileName.FilePath; Picture1GridMargin = String.Format("{0},{1},{2},{3}", template.Photos[0].Image.posX, template.Photos[0].Image.posY, 0, 0); Picture1Date = picture1FileName.DateTaken.ToString("d"); Picture1DateColor = template.Photos[0].Label.TextColor; Picture1Width = template.Photos[0].Image.Width; Picture1Height = template.Photos[0].Image.Height; } } catch (Exception ex) { log.writeLog(ex.ToString(), LogInfoType.Error); } }[/CODE] Any idea why this isn't updating. The LoadPage() method is called every 10 seconds via a timer tick event. [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
MediaPortal 2
Plugin Development
Binding Properties not updating
Contact us
RSS
Top
Bottom