Problem with updating binding properties (1 Viewer)

d2Liks

New Member
February 22, 2012
7
0
35
Home Country
Ukraine Ukraine
How do I implement refreshing of binding properties in MediaPortal2 similarly to Wpf INotifyPropertyChanged? Property triggers only with app loading, and all following values of that property on the form aren't refreshing after that.
 

d2Liks

New Member
February 22, 2012
7
0
35
Home Country
Ukraine Ukraine
cs:

private AbstractProperty _loginContentVisibility;

public AbstractProperty LoginContentVisibilityProperty
{
get { return _loginContentVisibility; }
}

public Visibility LoginContentVisibility
{
get { return (Visibility)_loginContentVisibility.GetValue(); }
set { _loginContentVisibility.SetValue(value); }
}

public PluginsModel()
{
_loginContentVisibility = new WProperty(typeof(Visibility), null);
//Although property is set to Collapsed after loading StackPanel will have value Visible. Where is a problem here?
LoginContentVisibility = Visibility.Collapsed;
}

XAML:
<StackPanel Visibility= "{Binding Path=LoginContentVisibility, Mode=TwoWay}" >
...
...
</StackPanel>

How should I implement the property so that I can manage Visiblity property for Xamle object?
 

morpheus_xx

Retired Team Member
  • Team MediaPortal
  • March 24, 2007
    12,073
    7,459
    Home Country
    Germany Germany
    you should check the Types first:
    • _loginContentVisibility = new WProperty(typeof(Visibility), null); <-- the null is the default, when not set. Your type Visibility.Collapsed looks like an Enum. You should use a proper default value of this enum.
    • you should check the binding: "{Binding Path=LoginContentVisibility, Mode=TwoWay}" isn't it enough to have only "{Binding Path=LoginContentVisibility}" ?
    I did not use the Visibility property yet (in fact I did not know it yet ;)), but when you like to control if the element should be visible, use the "IsVisible" property in favour (simple bool value).
     

    d2Liks

    New Member
    February 22, 2012
    7
    0
    35
    Home Country
    Ukraine Ukraine
    Problem isn't in Visibility only, any other properties don't refresh, get ccessors don't trigger, moreover binding works properly.

    One more question. How do I detect a click on the ListView element?

    How does next piece of code work?
    <ListView.Resources>
    <CommandBridge x:Key="Menu_Command" Command="{Binding Path=Command,Mode=OneTime}"/>
    </ListView.Resources>
     

    Albert

    MP2 Developer
  • Premium Supporter
  • February 18, 2008
    1,297
    1,130
    45
    Freiburg im Breisgau, Germany
    Home Country
    Germany Germany
    About the properties not refreshing, I have two comments:
    1) Your code seems well. I would guess your model isn't loaded/referenced correctly. In your previous postings, I saw you reference your model correctly per GUID so I think the problem is that you don't register the plugin in the plugin.xml file correctly. The SkinEngine can only load the model with a given GUID if it is registered using the <Model> element in plugin.xml.
    2) We currently don't support the visibility mode Collapsed at all. Collapsed and Hidden work exactly the same, that's why we always use the IsVisible property instead of the Visibility property.

    Did you try our example plugins in the Resources folder? Some things are explained there.
    It's sometimes hard to find a problem when the SkinEngine doesn't work as expected. You can look into the log output and for hard problems, you can switch on more log output in several classes, for example FrameworkElement, BindingMarkupExtension and some more. Sometimes, the only thing which helps is to debug the SkinEngine in the IDE.
    Furthermore, it might be easier to help you when you attach your complete plugin code.
     

    Albert

    MP2 Developer
  • Premium Supporter
  • February 18, 2008
    1,297
    1,130
    45
    Freiburg im Breisgau, Germany
    Home Country
    Germany Germany
    One more question. How do I detect a click on the ListView element?

    How does next piece of code work?
    <ListView.Resources>
    <CommandBridge x:Key="Menu_Command" Command="{Binding Path=Command,Mode=OneTime}"/>
    </ListView.Resources>

    That code provides a dynamic resource which is accessed by a DynamicMarkupExtension which is used somewhere in the ListView style. The reference is in file OtherControls.xaml #224.
     

    d2Liks

    New Member
    February 22, 2012
    7
    0
    35
    Home Country
    Ukraine Ukraine
    Hod should i organize data refreshing to make xaml data change?
    Could you tell me if MediaPortal2 supports MVVM?

    Plugin:
    <Plugin
    DescriptorVersion="1.0"
    Name="Plugins"
    PluginId="C28ABD6B-9615-4512-B8DA-A04096F35628"
    Author="d2L"
    Copyright="d2L"
    Description="Sample plugin"
    PluginVersion="0.1">

    <Runtime>
    <Assembly FileName="Plugins.dll"/>
    </Runtime>

    <Register Location="/Models">
    <Model Id="5726DA5A-70D5-458f-AF67-611293D97912" Name="ViewModel" ClassName="Plugins.Models.PluginModel"/>
    </Register>

    <Register Location="/Resources/Skin">
    <Resource Id="PluginsSkin" Directory="Skin" Type="Skin"/>
    </Register>

    <Register Location="/Resources/Language">
    <Resource Id="PluginsLanguage" Directory="Language" Type="Language"/>
    </Register>
    </Plugin>

    cs:
    private AbstractProperty _country;

    public AbstractProperty CountryProperty
    {
    get { return _country; }
    }
    public string Country
    {
    get { return (string)_country.GetValue(); }
    set { _country.SetValue(value); }
    }

    public PluginModel()
    {
    _country = new WProperty(typeof(string), null);
    }

    //There should be refresh after pressing on a button, but nothing happens
    public void SendMessage()
    {
    Country="Message";
    }


    xaml:
    <!-- Contents -->
    <ControlTemplate x:Key="Contents_Template" >
    <DockPanel Context="{Model Id=5726DA5A-70D5-458f-AF67-611293D97912}" LastChildFill="False">


    <DockPanel.Resources>
    <Model x:Key="ViewModel" Id="5726DA5A-70D5-458f-AF67-611293D97912"/>
    </DockPanel.Resources>
    <Button Style="{ThemeResource ButtonWideStyle}" Width="90" Margin="5,0,0,0" Command="{Command SendMessage}"></Button>
    <Label Content="{Binding Path=Country, Mode=TwoWay}" />

    </DockPanel>
    </ControlTemplate>
     

    Users who are viewing this thread

    Top Bottom