Problem with updating binding properties (1 Viewer)

d2Liks

New Member
February 22, 2012
7
0
32
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
32
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

Lead Dev MP2
  • Team MediaPortal
  • March 24, 2007
    11,488
    7,020
    Germany Germany
    Country flag
    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
    32
    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
    42
    Freiburg im Breisgau, Germany
    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
    42
    Freiburg im Breisgau, Germany
    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
    32
    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 (Users: 0, Guests: 1)

    OP Similar threads Forum Replies Date
    A Problem Windows 10 64 bit prof. Update auf Version 1903(gelöst) Installationsprobleme? 0
    H [solved] Problem bei Update auf 1.21 Installationsprobleme? 4
    W BluRay audio problem since update to MP 1.19 Watch / Listen Media 19
    F Problems with new install of MP2 Newcomers Forum 3
    A [solved] DiseqC problems after upgrade to 1.25 General Support 12
    M Problems with VFD Display after standby- Futaba DM140GINK Mini Display 0
    R Connection (api) problems with thetvdb.com General 3
    123vak123 [solved] 5008: The problem with scrolling text in the "listcontrol" in 4K General Support 22
    framug 1.24.0 1.25.0 pre : problem with build ? 1.24-1.26 Pre Release 89
    J Problems with 1.24 StreamedMP 19
    Rob Hexenmeister Navigation problems adding menu buttons to EPG General Support 1
    404 [solved] EPG problem after Win10 'upgrade' General Support 1
    framug [EPG] Some problems with DVB EPG Improvement Suggestions 49
    C strange tuner(?) problem TV-Cards 0
    R Problems accessing MySQL database remotely MediaPortal 1 Talk 0
    T [solved] Startup problem General 6
    G Problems with DRR MediaPortal 1 Talk 1
    rsbrux 1.23.0 MPE Manager Problem with LAV Filters Bugreports 2
    S Problem with Remote Control One-for-all Streamer Newcomers Forum 6
    joecrow Default Wide HD Xmas Theme Problem General Support 3
    K Sleep mode problem after formating General Support 2
    P IPTV Channel Problem TV-Server 0
    C Problem playing videos created on IPhone X and Samsung S9 General Support 2
    nominefi Problem scanning channels. General Support 0
    E Swedish subtitles problem General 2
    Top Bottom