मैं एमवीवीएम के साथ काम कर रहा हूं और पहिया को फिर से शुरू करने के बजाय, मैंने सोचा कि मुझे ओपन सोर्स व्यू मॉडल बेस क्लास मिल सकता है। मुझे एक नहीं मिल रहा है।एमवीवीएम - क्या एक खुला स्रोत मॉडल बेस क्लास देखें?
उत्तर
माइक्रोसॉफ्ट Prism। स्रोत कोड तक पूर्ण पहुंच। एक सीधी सीखने की वक्र का थोड़ा सा, लेकिन एक बार जब आप इसे संभालेंगे, तो यह वास्तव में अच्छी तरह से काम करता है।
यदि आपके पास ओओ और डिज़ाइन पैटर्न का अच्छा ज्ञान है, और यदि आपने पहले निर्भरता इंजेक्शन के साथ काम किया है तो खड़ी सीखने की वक्र फ़्लैट हो जाती है। –
क्या प्रिज्म में वास्तव में व्यूमोडेल बेस क्लास है? मैं कुछ परियोजनाओं पर प्रिज्म का उपयोग कर रहा हूं, और मैं वास्तव में उस पर कभी नहीं आया .... – BFree
वही प्रश्न: मैं प्रिज्म में बेस व्यूमोडेल का उपयोग कैसे करूं? इसमें कौन सी असेंबली/नेमस्पेस है? –
मैं सुझाव दूंगा कि एमवीवीएम के बुनियादी सिद्धांत इतने सरल हैं कि पहिया को फिर से शुरू करना आसान होगा। आपको आवश्यक सभी मूलभूत कार्यक्षमता कक्षा के लिए INotifyPropertyChanged
लागू करने के लिए है (बेस क्लास में OnPropertyChanged(string propertyName)
का मानक-शैली कार्यान्वयन हो सकता है)। इसके अलावा RelayCommand
या इसी तरह के - ICommand
कार्यान्वयन है जो Execute
में एक प्रतिनिधि को निष्पादित करता है।
ऑल-इन-सब, कोड की कुछ पंक्तियां, और यह बहुत साफ रखती है। आप किस अन्य कार्यक्षमता की तलाश में हैं? यदि यह अंतर्निहित बीडीओ से निपटने के लिए है (DataRow
, XmlNode
या पीओसीओ कहें) तो यह वास्तव में वीएम बेस क्लास में नहीं बल्कि एक व्युत्पन्न कक्षा में होना चाहिए।
उम्मीद है कि मदद करता है।
अपनी सिल्वरलाइटएफएक्स लाइब्रेरी के लिए निखेल कोठारी का ब्लॉग देखें, इसका एक खुला स्रोत एमवीवीएम आपको उपयोगी लगेगा।
MVVM Light भी एक अच्छा समाधान है, और यह आधार वर्ग को खोजने के लिए ... यह अभ्यस्त वास्तव में, आप मदद क्योंकि चाहते हैं मैं अपने ViewModels करना चाहते हैं :-)
मैं वास्तव में, वास्तव में चाहता हूं कि मैं अपने सुझाव को आगे रखने से पहले उस बारे में जानता हूं ;-) – heads5150
यहाँ मेरा का एक उदाहरण है एक वास्तव में आसान है तो अलग होगा तो आप अपने व्यूमोडल्स को क्या करना चाहते हैं ... लेकिन शायद यह आपको एक शुरुआत देगा। और आधार वर्ग के साथ बात करता है, तो आप इसे अपने कोर में रहना है ... आप केवल एक बार लिखने के लिए ...
Imports System.ComponentModel
Imports System.Windows
Imports Microsoft.Practices.Composite.Events
Imports WavelengthIS.Core.Services
Imports WavelengthIS.Core.Bases
Imports Ocean.OceanFramework.CommonDialog
Imports WavelengthIS.WPF.Events
Namespace WavelengthIS.WPF.Bases
Public MustInherit Class ViewModelBase
Inherits WavelengthIS.Core.Bases.Base
Implements IDisposable, INotifyPropertyChanged
#Region " Declarations "
Private _headerinfo As String
Private _backgroundworker As BackgroundWorker
#End Region
#Region " Properties "
Public Property HeaderInfo() As String
Get
Return _headerinfo
End Get
Set(ByVal value As String)
If Not (value Is String.Empty) Or Not (IsNothing(value)) Then
_headerinfo = value
End If
End Set
End Property
Protected ReadOnly Property BackGroundWorker() As BackgroundWorker
Get
If _backgroundworker Is Nothing Then
_backgroundworker = New BackgroundWorker
End If
Return _backgroundworker
End Get
End Property
Private _isdirty As Boolean = False
Protected Property IsDirty As Boolean
Get
Return _isdirty
End Get
Set(ByVal value As Boolean)
If Not Equals(value, _isdirty) Then
_isdirty = value
If _isdirty = True Then
DisableNavigation()
Else
EnableNavigation()
End If
End If
End Set
End Property
''' <summary>
''' not a databinding property. No need for onpropertychanged notifications
''' </summary>
''' <value></value>
''' <returns></returns>
''' <remarks></remarks>
Protected Property IsLoading As Boolean = False
Private _haschanges As Boolean
Public Property HasChanges As Boolean
Get
Return _haschanges
End Get
Set(ByVal value As Boolean)
If Not Equals(value, _haschanges) Then
_haschanges = value
If value = True Then
GetEvent(Of Events.DisableCloseButtonEvent).Publish(True)
End If
OnPropertyChanged("HasChanges")
End If
End Set
End Property
#End Region
#Region " Dialogs "
'This is not in Bases because it would cause circular references.
''' <summary>
''' Gets the IDialogService registered with the ServiceContainer.
''' use ShowMessage or ShowException in child code.
''' </summary>
Private ReadOnly Property Dialog() As Dialog.IDialogService
Get
Return GetService(Of Dialog.IDialogService)()
End Get
End Property
Protected Function ShowMessage(ByVal message As String, ByVal caption As String, ByVal button As Dialog.DialogButton, ByVal image As Dialog.DialogImage) As Ocean.OceanFramework.CommonDialog.CustomDialogResult
GetEvent(Of Events.DialogShowingEvent).Publish(True)
Dim rslt As CustomDialogResult = Dialog.ShowMessage(message, caption, button, image)
GetEvent(Of Events.DialogShowingEvent).Publish(False)
Return rslt
End Function
Protected Sub ShowException(ByVal message As String, Optional ByVal expandedMessage As String = Nothing, Optional ByVal image As Dialog.DialogImage = Core.Services.Dialog.DialogImage.Error)
GetEvent(Of Events.DialogShowingEvent).Publish(True)
Dialog.ShowException(message, expandedMessage, image)
GetEvent(Of Events.DialogShowingEvent).Publish(False)
End Sub
#End Region
#Region " Wait States "
Private ReadOnly Property Wait As WavelengthIS.Core.Services.IWaitingService
Get
Return GetService(Of IWaitingService)()
End Get
End Property
Protected Sub BeginWait()
GetEvent(Of Events.DisplayWaitingControlEvent).Publish(True)
End Sub
Protected Sub EndWait()
GetEvent(Of Events.DisplayWaitingControlEvent).Publish(False)
End Sub
#End Region
#Region " Events "
Public Event PropertyChanged(ByVal sender As Object, ByVal e As System.ComponentModel.PropertyChangedEventArgs) Implements System.ComponentModel.INotifyPropertyChanged.PropertyChanged
#End Region
#Region " Constructor "
Public Sub New()
_backgroundworker = New BackgroundWorker
AddHandler _backgroundworker.DoWork, AddressOf BackGroundWorker_DoWork
AddHandler _backgroundworker.RunWorkerCompleted, AddressOf BackGroundWorker_RunWorkerCompleted
End Sub
#End Region
#Region " IDisposable Support "
Private disposedValue As Boolean = False ' To detect redundant calls
' IDisposable
Protected Overridable Sub Dispose(ByVal disposing As Boolean)
If Not Me.disposedValue Then
If disposing Then
' TODO: free other state (managed objects).
End If
' TODO: free your own state (unmanaged objects).
' TODO: set large fields to null.
End If
Me.disposedValue = True
End Sub
' This code added by Visual Basic to correctly implement the disposable pattern.
Public Sub Dispose() Implements IDisposable.Dispose
' Do not change this code. Put cleanup code in Dispose(ByVal disposing As Boolean) above.
Dispose(True)
GC.SuppressFinalize(Me)
End Sub
#End Region
#Region " Debugging Helpers "
<Conditional("DEBUG")> _
Public Sub VerifyPropertyName(ByVal propertyName As String)
'If you raise PropertyChanged and do not specify a property name,
'all properties on the object are considered to be changed by the binding system.
If String.IsNullOrEmpty(propertyName) Then
Return
End If
' Verify that the property name matches a real,
' public, instance property on this object.
'If TypeDescriptor.GetProperties(Me)(propertyName) Is Nothing Then
' Dim msg As String = "Invalid property name: " & propertyName
' Throw New Exception(msg)
'End If
End Sub
Private _ThrowOnInvalidPropertyName As Boolean
Protected Property ThrowOnInvalidPropertyName() As Boolean
Get
Return _ThrowOnInvalidPropertyName
End Get
Private Set(ByVal value As Boolean)
_ThrowOnInvalidPropertyName = value
End Set
End Property
#End Region
#Region " INotifyProperty Changed Method "
Protected Overridable Sub OnPropertyChanged(ByVal strPropertyName As String)
Me.VerifyPropertyName(strPropertyName)
If Me.PropertyChangedEvent IsNot Nothing Then
RaiseEvent PropertyChanged(Me, New System.ComponentModel.PropertyChangedEventArgs(strPropertyName))
End If
End Sub
Private Function QualifyString(ByVal str As String) As Boolean
Return True
End Function
Protected Overridable Sub OnPropertyChanged(ByVal strPropertyName As String, ByVal IsPrimaryProperty As Boolean)
Me.OnPropertyChanged(strPropertyName)
End Sub
#End Region
#Region " Navigation Events "
Protected Sub EnableNavigation()
'Keep from firing multiple onPropertyChanged events
If HasChanges = True Then
HasChanges = False
End If
GetEvent(Of DisableNavigationEvent).Publish(False)
End Sub
Protected Sub DisableNavigation()
'Keep from firing multiple onPropertyChanged events
If HasChanges = False Then
HasChanges = True
End If
GetEvent(Of DisableNavigationEvent).Publish(True)
End Sub
#End Region
End Class
End Namespace
यह प्रश्न सी # के साथ टैग किया गया है। – Mizipzor
WPF Application Framework (WAF) है खुला स्रोत है और (के लिए एक ViewModel आधार वर्ग में शामिल है मॉडल-व्यू-व्यू मॉडेल पैटर्न को कार्यान्वित करना)।
SoapBox Core एक्स्टेंसिबल एमवीवीएम अनुप्रयोगों के निर्माण के लिए एक ओपन सोर्स (एलजीपीएल) एमवीवीएम (और एमईएफ) ढांचा है। कक्षा पदानुक्रम में बेस व्यू मॉडेल क्लास (और उस मामले के लिए इंटरफ़ेस) शामिल है।
- 1. एमवीवीएम बेस व्यू मॉडल क्लास
- 2. डब्ल्यूपीएफ - एमवीवीएम - मॉडल पदानुक्रम देखें
- 3. WPF एमवीवीएम देखें मॉडल और मॉडल रिलेशनशिप
- 4. कार्यान्वयन सार बेस मॉडल क्लास, रेल मार्ग ™
- 5. एक सामान्य बेस क्लास
- 6. एमवीवीएम संवाद में डेटा पास करना मॉडल देखें
- 7. बेस्ट खुला स्रोत लिनक्स
- 8. OAuth - खुला स्रोत अनुप्रयोगों
- 9. बेस क्लास
- 10. बेस क्लास
- 11. बेस क्लास
- 12. खुला स्रोत आभासी मशीन
- 13. बेस क्लास
- 14. बेस क्लास
- 15. बेस क्लास
- 16. बेस क्लास
- 17. सी ++: एक बेस क्लास पॉइंटर
- 18. खुला स्रोत विकल्प
- 19. सार बेस क्लास
- 20. बेस क्लास
- 21. बेस क्लास
- 22. क्या कोई खुला स्रोत एआई इंजन है?
- 23. एमवीवीएम लाइट मेसेंजर क्लास
- 24. एमवीवीएम: पतला दृश्य मॉडल और रिच मॉडल
- 25. बेस क्लास बनाम यूटिलिटी क्लास
- 26. एमवीवीएम मॉडल देखने के लिए मॉडल संचार
- 27. क्या अमेज़ॅन एसएनएस के बराबर एक खुला स्रोत है?
- 28. क्या अमेज़ॅन एस 3 के बराबर एक खुला स्रोत है?
- 29. एमवीवीएम - मॉडल और व्यूमोडेल
- 30. एमवीवीएम
आप इस बेस क्लास में क्या देख रहे हैं? –