在XAML(UWP)中绑定Singleton

时间:2018-05-04 12:41:10

标签: c# .net xaml uwp

我尝试将Listview的Itemsource属性绑定到我的Singelton StaticEntryList.Instance ...如何使用UWP(x:静态不可用)

谢谢:)

namespace SE_Projekt
{
    public class StaticEntryList:List<Entry> {

        private static StaticEntryList _Instance;
        public static StaticEntryList Instance
        {
            get
            {
                if (_Instance == null) {
                    _Instance = new EntryList();
                }
                return _Instance;
            }
        }

        private StaticEntryList()
        {

        }
        //...
    }
}

这里是MainPage.xaml

<ListView Name="StaticEntryListView" Grid.Column="0" ItemTemplate="{StaticResource StaticEntryTemplate}" ItemsSource="{x:Bind ??? :("> </ListView>

1 个答案:

答案 0 :(得分:1)

您只需要使用类命名空间启动绑定路径:

seproject

Page是在UserControl / <Page x:Class="StaticBindign.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:seproject="using:SE_Projekt" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d"> 根元素中声明的命名空间标记:

@Entity
@Table(name = "user")
@Inheritance(strategy=InheritanceType.TABLE_PER_CLASS)
public class User{

@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;

@NotNull
@JsonIgnore
@Column(name = "password")
private String password;

@NotNull
@Email
private String email;

@Column(name = "phone_number")
private String phoneNumber;



@JsonIgnore
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "id",insertable = false,updatable = false)
private RoleDAO roleDAO;

@JsonManagedReference
@OneToMany(mappedBy = "user", cascade = CascadeType.ALL)
private List<Ticket> tickets;

仅在定位(至少)Windows周年更新(版本14393)SDK

时才有效