A part of the .NET Framework that provides a unified programming model for building line-of-business desktop applications on Windows.
Using the toolkit in the manner shown by my code is only possible with C#.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I've decided to give the CommunityToolkit a try but my code and the parts of the Toolkit are not making a connection.
Here's the relevant parts of my MainWi8ndow:
<Window
x:Class="MainWindow"
<Window.DataContext>
<self:MainWindowVM />
</Window.DataContext>
<Label
Content="{Binding Path=FirstLabel}" />
<Button
Command="{Binding Path=ExitMe}"
Content="Exit" />
</Window>
And the View Model:
Imports CommunityToolkit.Mvvm.ComponentModel
Imports CommunityToolkit.Mvvm.Input
Partial Public Class MainWindowVM
Inherits ObservableObject
....
<RelayCommand>
Private Sub ExitMe()
Windows.Application.Current.Shutdown()
End Sub
....
<ObservableProperty>
Private FirstLabel As String
....
<End Class
At run-time I get two error messages:
ExitMe' property not found on 'object' ''MainWindowVM'
That is obviously a correct error message but that is the way it is done in an example I am using as a guide.
BindingExpression path error: 'FirstLabel' property not found on 'object' ''MainWindowVM'
That one I don't understand. My understanding is that the toolkit generates the Public property from the private declaration. Is that not correct?
Thanks in advance for the help.
A part of the .NET Framework that provides a unified programming model for building line-of-business desktop applications on Windows.
An object-oriented programming language developed by Microsoft that can be used in .NET.
Using the toolkit in the manner shown by my code is only possible with C#.
You could use the following code.
Imports CommunityToolkit.Mvvm.ComponentModel
Imports CommunityToolkit.Mvvm.Input
Class MainWindow
End Class
Partial Public Class MainWindowVM
Inherits ObservableObject
Public Sub New()
Me.FirstLabel = "default value..."
Me.ExitMe = New RelayCommand(AddressOf exMe)
End Sub
<ObservableProperty>
Private fLabel As String
Public Property FirstLabel As String
Private Sub Save()
Me.fLabel = FirstLabel
End Sub
<RelayCommand>
Private Sub exMe()
Windows.Application.Current.Shutdown()
End Sub
Public ReadOnly Property ExitMe As ICommand
End Class
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.