[英]How do I call an attribute value from one model class to another model class?
我在Service.cs
類中有一個名為ServiceName
的屬性,並且我希望在另一個類Booking.cs
顯示相同的值,而無需再次輸入。
public class Service
{
public string ServiceName { get; set; }
}
public class Booking
{
[DisplayName("Service Chosen")]
public string ServiceName { get; set; }
}
因此,您必須在兩個類之間進行通信,因此您必須使用Prism EventAggregator之類的東西,如果它的更改如
public string ServiceName
{
get { return _serviceName; }
set
{
_serviceName = value;
EventAggregator.GetEvent<eventname>().Publish(_serviceName);
}
}
並使用EventAggregator.GetEvent<eventname>().Subscribe(YourSubscribeMethod);
您可以在這里閱讀有關內容https://prismlibrary.github.io/docs/event-aggregator.html
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.