Tracking the CurrentChanged event of an ICollectionView declared as a dependencyProperty - wpf

I have an ICollectionView declared like so;
Public Shared ReadOnly DataIcvProperty As DependencyProperty = DependencyProperty.Register("DataIcv", GetType(ICollectionView), GetType(DataNavigator), New PropertyMetadata(Nothing))
<Description("The CollectionView (as an ICollectionView) to be passed to the DataNavigator control"), Category("Navigation Data Source")>
Public Property DataIcv As ICollectionView
Get
Return GetValue(DataIcvProperty)
End Get
Set(ByVal Value As ICollectionView)
SetValue(DataIcvProperty, Value)
End Set
End Property
On which I would like to keep track of the CurrentChanged event. So in the constructor of a wpf userControl (in which this property is declared I have added the following:
AddHandler DataIcv.CurrentChanged, AddressOf OnDataICVCurrentChanged
and then added the following
Public Sub OnDataICVCurrentChanged(ByVal sender As Object, e As EventArgs) Handles internalIcv.CurrentChanged
'Do whatever needs doing when the record in the ICollectionView changes
End Sub
When I then compile the usercontrol and use it in a separate project I get a NullReferenceException on the AddHandler line in the Constructor of the control (without any inner exception details).
What do I need to do to keep track of the current Changed event of the DataIcv so that I can have elements of my user control react properly to those changes?
Thanks
EDIT
This relates to the issue I described here. Essentially I want the navigator control to reflect the fact that the end user might select rows on the grid independently of the navigator.

The problem is, when you try to subscribe to the CurrentChanged event in your constructor, the DependencyProperty DataIcvProperty has a default value Nothing (as you specified in your property registration). So the NullReferenceException.
You could solve this with a PropertyChangeCallback (see documentation).
I come from the C# world and cannot guarantee the right syntax for VB.NET, but this approach surely will work:
Public Shared ReadOnly DataIcvProperty As DependencyProperty =
DependencyProperty.Register("DataIcv",
GetType(ICollectionView), GetType(DataNavigator),
New FrameworkPropertyMetadata(
Nothing,
New PropertyChangedCallback(AddressOf OnDataIcvChanged)))
Then you need to implement the OnDataIcvChanged static method, which will be called every time the property value changes.
Private Shared Sub OnDataIcvChanged(ByVal d As DependencyObject, ByVal e As DependencyPropertyChangedEventArgs)
If e.OldValue IsNot Nothing
RemoveHandler (e.OldValue As ICollectionView).CurrentChanged, AddressOf OnDataICVCurrentChanged
EndIf
If e.NewValue IsNot Nothing
AddHandler (e.NewValue As ICollectionView).CurrentChanged, AddressOf OnDataICVCurrentChanged
EndIf
End Sub
Update:
If your event handler method is not static, then you should access it via the object instance:
Private Shared Sub OnDataIcvChanged(ByVal d As DependencyObject, ByVal e As DependencyPropertyChangedEventArgs)
Dim DataNavigator instance = d As DataNavigator
If e.OldValue IsNot Nothing
RemoveHandler (e.OldValue As ICollectionView).CurrentChanged, AddressOf instance.OnDataICVCurrentChanged
EndIf
If e.NewValue IsNot Nothing
AddHandler (e.NewValue As ICollectionView).CurrentChanged, AddressOf instance.OnDataICVCurrentChanged
EndIf
End Sub
Edit: Code That eventually worked:
Public Shared ReadOnly DataIcvProperty As DependencyProperty = DependencyProperty.Register("DataIcv", GetType(ICollectionView), GetType(DataNavigator), New FrameworkPropertyMetadata(Nothing, New PropertyChangedCallback(AddressOf OnDataIcvChanged)))
<Description("The CollectionView (as an ICollectionView) to be passed to the DataNavigator control"), Category("Navigation Data Source")>
Public Property DataIcv As ICollectionView
Get
Return CType(GetValue(DataIcvProperty), ICollectionView)
End Get
Set(ByVal Value As ICollectionView)
SetValue(DataIcvProperty, Value)
End Set
End Property
Private Shared Sub OnDataIcvChanged(ByVal d As DependencyObject, ByVal e As DependencyPropertyChangedEventArgs)
Dim dn As DataNavigator = CType(d, DataNavigator)
If e.OldValue IsNot Nothing Then
RemoveHandler dn.DataIcv.CurrentChanged, AddressOf dn.OnDataICVCurrentChanged
End If
If e.NewValue IsNot Nothing Then
AddHandler dn.DataIcv.CurrentChanged, AddressOf dn.OnDataICVCurrentChanged
End If
End Sub
Private Sub OnDataICVCurrentChanged(ByVal sender As Object, ByVal e As EventArgs)
Record.Text = (DataIcv.CurrentPosition + 1).ToString
End Sub

Related

Implementing New UIPropertyMetadata for DependencyProperty in VS 2008 with VB.net 3.5

Using Visual Studio 2008 with VB.net 3.5. Trying to implement a sorting solution from [WPF] AUTOMATICALLY SORT A GRIDVIEW WHEN A COLUMN HEADER IS CLICKED by Thomas Levesque
his code converted to VB.net by converter.telerik.com
Public Shared ReadOnly CommandProperty As DependencyProperty = DependencyProperty.RegisterAttached("Command", GetType(ICommand), GetType(GridViewSort), New UIPropertyMetadata(Nothing, Function(o, e)
Dim listView As ItemsControl = TryCast(o, ItemsControl)
If listView IsNot Nothing Then
If Not GetAutoSort(listView) Then
' Don't change click handler if AutoSort enabled
If e.OldValue IsNot Nothing AndAlso e.NewValue Is Nothing Then
listView.[RemoveHandler](GridViewColumnHeader.ClickEvent, New RoutedEventHandler(AddressOf ColumnHeader_Click))
End If
If e.OldValue Is Nothing AndAlso e.NewValue IsNot Nothing Then
listView.[AddHandler](GridViewColumnHeader.ClickEvent, New RoutedEventHandler(AddressOf ColumnHeader_Click))
End If
End If
End If
End Function))
Using old IDE I can't use it as given. I tried to convert the function to a regular function but I'm not sure where the o and e come from.
Public Shared ReadOnly CommandProperty As DependencyProperty = DependencyProperty.RegisterAttached("Command", GetType(ICommand), GetType(GridViewSort), New UIPropertyMetadata(Nothing, getFuncA))
Public Shared Function getFuncA(ByVal o As DependencyObject, ByVal e As DependencyPropertyChangedEventArgs)
Dim listView As ItemsControl = TryCast(o, ItemsControl)
If listView IsNot Nothing Then
If Not GetAutoSort(listView) Then
' Don't change click handler if AutoSort enabled
If e.OldValue IsNot Nothing AndAlso e.NewValue Is Nothing Then
listView.[RemoveHandler](GridViewColumnHeader.ClickEvent, New RoutedEventHandler(AddressOf ColumnHeader_Click))
End If
If e.OldValue Is Nothing AndAlso e.NewValue IsNot Nothing Then
listView.[AddHandler](GridViewColumnHeader.ClickEvent, New RoutedEventHandler(AddressOf ColumnHeader_Click))
End If
End If
End If
End Function
Compiler error o is not declared and e is not declared. How do I convert this to VB.net 3.5 using VS 2008. Thanks.
Thanks to ASh comment. I just had to properly declare the getFuncA and use AddressOf getFuncA
Public Shared ReadOnly CommandProperty As DependencyProperty = DependencyProperty.RegisterAttached("Command", _
GetType(ICommand), _
GetType(GridViewSort), _
New UIPropertyMetadata(Nothing, AddressOf getFuncA))
Public Shared Function getFuncA(ByVal o As DependencyObject, ByVal e As DependencyPropertyChangedEventArgs)
Dim listView As ItemsControl = TryCast(o, ItemsControl)
If listView IsNot Nothing Then
If Not GetAutoSort(listView) Then
' Don't change click handler if AutoSort enabled
If e.OldValue IsNot Nothing AndAlso e.NewValue Is Nothing Then
listView.[RemoveHandler](GridViewColumnHeader.ClickEvent, _
New RoutedEventHandler(AddressOf ColumnHeader_Click))
End If
If e.OldValue Is Nothing AndAlso e.NewValue IsNot Nothing Then
listView.[AddHandler](GridViewColumnHeader.ClickEvent, _
New RoutedEventHandler(AddressOf ColumnHeader_Click))
End If
End If
End If
End Function

Binding to ICommand with MVVM

I'm totally new with MVVM and its stuff.
Could you help me to correctly bind the WPF button to ICommand.
I'm binding the button:
<Button Command="{Binding OpenWindow}" >
In the ViewModel:
Public Sub New()
OpenWindow = New RelayCommand(New Action(Of Object)(AddressOf ShowWindow))
End Sub
Private Sub ShowWindow()
Dim win As New SecondWindow()
win.Show()
End Sub
And I have the class RelayCommand as:
Public Class RelayCommand
Implements ICommand
Private ReadOnly _CanExecute As Func(Of Boolean)
Private ReadOnly _Execute As Action
Public Sub New(ByVal execute As Action)
Me.New(execute, Nothing)
End Sub
Public Sub New(ByVal execute As Action, ByVal canExecute As Func(Of Boolean))
If execute Is Nothing Then
Throw New ArgumentNullException("execute")
End If
_Execute = execute
_CanExecute = canExecute
End Sub
Public Custom Event CanExecuteChanged As EventHandler Implements System.Windows.Input.ICommand.CanExecuteChanged
AddHandler(ByVal value As EventHandler)
If _CanExecute IsNot Nothing Then
AddHandler CommandManager.RequerySuggested, value
End If
End AddHandler
RemoveHandler(ByVal value As EventHandler)
If _CanExecute IsNot Nothing Then
RemoveHandler CommandManager.RequerySuggested, value
End If
End RemoveHandler
RaiseEvent(ByVal sender As Object, ByVal e As System.EventArgs)
CommandManager.InvalidateRequerySuggested()
End RaiseEvent
End Event
Public Function CanExecute(ByVal parameter As Object) As Boolean Implements System.Windows.Input.ICommand.CanExecute
If _CanExecute Is Nothing Then
Return True
Else
Return _CanExecute.Invoke
End If
End Function
Public Sub Execute(ByVal parameter As Object) Implements System.Windows.Input.ICommand.Execute
_Execute.Invoke()
End Sub
End Class
With the above, I have an exception in the ViewModel constructor part saying "Nested sub does not have a signature that is compatible with delegate 'Delegate Sub Action()'. What am I doing wrong?
Change it to this:
OpenWindow = New RelayCommand(New Action(AddressOf ShowWindow))
The RelayCommand requires an action without parameters. Your method ShowWindow also is a method without parameters. But you declare the action with one parameter of type Object.

Two-way WPF binding to Properties of a class inside of an ObservableCollection

I've searched as best as I can, and I can't find an answer to this specific problem that I have... WPF binding seems to be great and all, but I end up banging my head against the wall more often than not.
Okay, I have a singleton class which is ultimately the one that I'm binding to:
Imports System.ComponentModel
Imports System.Collections.ObjectModel
Public Class AmandaSeyfried
Implements INotifyPropertyChanged
Shared _config As New config
Public Event PropertyChanged(sender As Object, E As PropertyChangedEventArgs) Implements INotifyPropertyChanged.PropertyChanged
Protected Overridable Sub OnPropertyChanged(propertyName As String)
RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(propertyName))
End Sub
Private Shared _thisInstance As AmandaSeyfried
Protected Sub New()
' initialization goes here
End Sub
Public Shared Function GetSingleton() As AmandaSeyfried
' initialize object if it hasn't already been done
If _thisInstance Is Nothing Then
_thisInstance = New AmandaSeyfried
End If
' return the initialized instance
Return _thisInstance
End Function
Public Class CountryTranslation
Implements INotifyPropertyChanged
Private Property _englishCountryName As String = ""
Public Property EnglishCountryName As String
Get
Return _EnglishCountryName
End Get
Set(value As String)
If _englishCountryName <> value Then
_englishCountryName = value
RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs("EnglishCountryName"))
End If
End Set
End Property
Private Property _foreignCountryName As String = ""
Public Property ForeignCountryName As String
Get
Return _foreignCountryName
End Get
Set(value As String)
If _foreignCountryName <> value Then
_foreignCountryName = value
RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs("ForeignCountryName"))
End If
End Set
End Property
Public Event PropertyChanged(sender As Object, e As System.ComponentModel.PropertyChangedEventArgs) Implements System.ComponentModel.INotifyPropertyChanged.PropertyChanged
End Class
Private WithEvents _countryTranslations As New ObservableCollection(Of CountryTranslation)
Public Property CountryTranslations As ObservableCollection(Of CountryTranslation)
Get
If _config.GetKeyTextValue("countryTranslations") <> "" Then
Dim reader As New IO.StringReader(_config.GetKeyTextValue("countryTranslations"))
Dim Serializer As New Xml.Serialization.XmlSerializer(_countryTranslations.GetType)
_countryTranslations = Serializer.Deserialize(reader)
End If
Return _countryTranslations
End Get
Set(value As ObservableCollection(Of CountryTranslation))
_countryTranslations = value
RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs("CountryTranslations"))
End Set
End Property
Private Sub CountryTranslationCollectionChanged(sender As Object, e As Specialized.NotifyCollectionChangedEventArgs) Handles _countryTranslations.CollectionChanged
Dim newStringWriter As New IO.StringWriter
Dim NewSerializer As New Xml.Serialization.XmlSerializer(_countryTranslations.GetType)
NewSerializer.Serialize(newStringWriter, _countryTranslations)
_config.SaveKeyTextValue("countryTranslations", newStringWriter.ToString)
RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs("CountryTranslations"))
End Sub
End Class
_config is a misnamed helper class that stores and retrieves data from a local SqlCe instance. Essentially the object is serialized, stored in the DB, and then pulled out of the DB any times it's needed and deserialized back into an object. All in all, it seems to be working fairly well.
My problem is that although I can bind to the object, and I can monitor when a row is added in a WPF DataGrid via the CollectionChangedMethod handler, I don't get any notification when either of the two properties of CountryTranslation are changed.
The rest of my related code is... XAML... there's obviously more, but I don't believe the XAML portion of the binding is to blame, so I'll trim it to the relevant:
<toolkit:DataGrid Margin="12,12,12,12" ItemsSource="{Binding Path=KarenSmith.CountryTranslations, Mode=TwoWay}" AutoGenerateColumns="False" HorizontalAlignment="Stretch" Width="Auto" SelectionMode="Single">
<toolkit:DataGrid.Columns>
<toolkit:DataGridTextColumn Width="283" Binding="{Binding EnglishCountryName,Mode=TwoWay}" />
<toolkit:DataGridTextColumn Width="283" Binding="{Binding ForeignCountryName,Mode=TwoWay}" />
</toolkit:DataGrid.Columns>
</toolkit:DataGrid>
And the nice and simple code-behind:
Public Class Preferences
Public Property KarenSmith As AmandaSeyfried = AmandaSeyfried.GetSingleton
Sub New()
' This call is required by the designer.
InitializeComponent()
' Add any initialization after the InitializeComponent() call.
DataContext = Me
End Sub
Private Sub Close_Click(sender As System.Object, e As System.Windows.RoutedEventArgs)
Me.Close()
End Sub
End Class
If I throw some break points on the Getter and Setters of the CountryTranslation class, I can monitor when they're being changed (via the datagrid, so binding is working), but try as I might I can't figure out how to raise an event based upon that back in the main class to subsequently update the datastore to show the changes.
Usually I add a CollectionChanged event to the ObservableCollection, which attaches a PropertyChanged event to it's items when they get added, and that event listener listens for changes and would handle them as needed.
Here's an example: (hope the syntax is correct since I just ran it through a C# to VB.Net converter)
Public Sub New()
AddHandler MyCollection.CollectionChanged, AddressOf MyCollection_CollectionChanged
End Sub
Private Sub MyCollection_CollectionChanged(sender As Object, e As CollectionChangedEventArgs)
If e.NewItems IsNot Nothing Then
For Each item As MyItem In e.NewItems
AddHandler item.PropertyChanged, AddressOf MyItem_PropertyChanged
Next
End If
If e.OldItems IsNot Nothing Then
For Each item As MyItem In e.OldItems
RemoveHandler item.PropertyChanged, AddressOf MyItem_PropertyChanged
Next
End If
End Sub
Private Sub MyItem_PropertyChanged(sender As Object, e As PropertyChangedEventArgs)
If e.PropertyName = "Some Property" Then
DoWork()
End If
End Sub
The C# version looks like this:
public MyViewModel()
{
MyCollection.CollectionChanged += MyCollection_CollectionChanged;
}
void MyCollection_CollectionChanged(object sender, CollectionChangedEventArgs e)
{
if (e.NewItems != null)
foreach(MyItem item in e.NewItems)
item.PropertyChanged += MyItem_PropertyChanged;
if (e.OldItems != null)
foreach(MyItem item in e.OldItems)
item.PropertyChanged -= MyItem_PropertyChanged;
}
void MyItem_PropertyChanged(object sender, PropertyChangedEventArgs e)
{
if (e.PropertyName == "Some Property")
DoWork();
}

Trying to register DependencyProperty for WebBrowser Control

I'm trying to get the WebBrowser control to display HTML loaded from a variable. I found this solution Displaying html from string in WPF WebBrowser control so am trying to implement my first DependencyProperty.
Here's my attempt at the implementation:
Public Shared ReadOnly HtmlProperty As DependencyProperty = DependencyProperty.RegisterAttached("Html", GetType(String), GetType(PortraitSingle), New FrameworkPropertyMetadata(OnHtmlChanged))
<AttachedPropertyBrowsableForType(GetType(WebBrowser))> _
Public Shared Function GetHtml(ByVal d As WebBrowser) As String
Return DirectCast(d.GetValue(HtmlProperty), String)
End Function
Public Shared Sub SetHtml(ByVal d As WebBrowser, ByVal value As String)
d.SetValue(HtmlProperty, value)
End Sub
Private Shared Sub OnHtmlChanged(ByVal d As DependencyObject, ByVal e As DependencyPropertyChangedEventArgs)
Dim wb As WebBrowser = TryCast(d, WebBrowser)
If wb IsNot Nothing Then
wb.NavigateToString(TryCast(e.NewValue, String))
End If
End Sub
and the XAML
<WebBrowser x:Name="HTMLDescription" Grid.RowSpan="2" Margin="10" local:PortraitSingle.Html="{Binding HtmlToDisplay}"></WebBrowser>
First off, the problem I'm having is I'm getting the following errors:
Argument not specified for parameter 'e' of 'Private Shared Sub OnHtmlChanged(d As System.Windows.DependencyObject, e As System.Windows.DependencyPropertyChangedEventArgs)
and
The attachable property 'Html' was not found in type 'PortraitSingle'. (PortraitSingle is the name of my Window).
I can't work out how to get around them.
Also, I can't understand how I actually load my HTML into the WebBrowser control.
Ben
Found my problem.
Needed to add the 'AddressOf' to the DependencyProperty statement
Public Shared ReadOnly HtmlProperty As DependencyProperty = DependencyProperty.RegisterAttached("Html", GetType(String), GetType(PortraitSingle), New FrameworkPropertyMetadata(AddressOf OnHtmlChanged))

Periodically update silverlight view with MVVM

I am trying to use MVVM in Silverlight, but I am quite new to it so I am not quite sure on some things. I have a silverlight page which displays the progress of some server side operation. The current progress comes from a web service and should be refreshed every few seconds (lets say 10 seconds for the sake of the argument).
What is the best way to implement this? The options I could think of was:
Initalize a DispatcherTimer in the Initalize method of my ViewModel and refresh the view from the DispatcherTimer event (putting the timer details in the ViewModel)
Create a wrapper arround DispatcherTimer (e.g. PeriodicCommandExecutor) which would be a Control or resource similar to the Timer control in WindowsForms with a command property that I bind to a Refresh command in the ViewModel (putting the timer details in the View)
I think the second option is preferred, because it makes the ViewModel easier to test and DispatcherTimer is an UI implementation detail which I don't want in my ViewModel propably. Do you agree?
If yes, how would you create such a wrapper. I started doing an DependencyObject with attached properties, but I am not sure how to forward the property values like Interval to the internal DispatcherTimer. Silverlight doesn't seem to provide any events when the dependency properties change and DispatcherTimer is not a DependencyObject so I can't databind directly to its properties.
Thanks!
Why use a DispatcherTimer? Why not use an ordinary System.Threading.Timer, which will fire its callback on a background thread?
If you put your UI progress update somewhere inconspicious (i.e. not in the centre of the UI, maybe in a bottom corner or status bar), then have the background timer chugging away while the user carries on with what they were doing. The progress value can be populated into the viewmodel, and shown on the UI using binding. This way you don't have to tie up the UI thread making web service calls.
At the end I solved my dillema creating a behavior which periodically executes a refresh command on the ViewModel which you can specify.
The code for the behavior is like this
(sorry for VB code):
Option Strict On
Imports System.Windows.Threading
Imports System.Windows.Interactivity
Namespace View.Behaviors
Public Class RefreshBehavior
Inherits Behavior(Of FrameworkElement)
Public Property Command As ICommand
Get
Return DirectCast(GetValue(CommandProperty), ICommand)
End Get
Set(ByVal value As ICommand)
SetValue(CommandProperty, value)
End Set
End Property
Public Shared ReadOnly CommandProperty As DependencyProperty = _
DependencyProperty.Register("Command", _
GetType(ICommand), GetType(RefreshBehavior), _
New PropertyMetadata(Nothing))
Public Property CommandParameter As Object
Get
Return GetValue(CommandParameterProperty)
End Get
Set(ByVal value As Object)
SetValue(CommandParameterProperty, value)
End Set
End Property
Public Shared ReadOnly CommandParameterProperty As DependencyProperty = _
DependencyProperty.Register("CommandParameter", _
GetType(Object), GetType(RefreshBehavior), _
New PropertyMetadata(Nothing))
Public Property Interval As TimeSpan
Get
Return DirectCast(GetValue(IntervalProperty), TimeSpan)
End Get
Set(ByVal value As TimeSpan)
SetValue(IntervalProperty, value)
End Set
End Property
Public Shared ReadOnly IntervalProperty As DependencyProperty = _
DependencyProperty.Register("Interval", _
GetType(TimeSpan), GetType(RefreshBehavior), _
New PropertyMetadata(TimeSpan.Zero, AddressOf OnIntervalUpdate))
Public Property Enabled As Boolean
Get
Return DirectCast(GetValue(EnabledProperty), Boolean)
End Get
Set(ByVal value As Boolean)
SetValue(EnabledProperty, value)
End Set
End Property
Public Shared ReadOnly EnabledProperty As DependencyProperty = _
DependencyProperty.Register("Enabled", _
GetType(Boolean), GetType(RefreshBehavior), _
New PropertyMetadata(False, AddressOf OnEnabledUpdate))
Dim WithEvents timer As New DispatcherTimer()
Private Shared Sub OnEnabledUpdate(ByVal d As DependencyObject, ByVal e As DependencyPropertyChangedEventArgs)
Dim enable As Boolean = CType(e.NewValue, Boolean)
Dim executor As RefreshBehavior = CType(d, RefreshBehavior)
If Not executor.attached Then Return
Dim timer As DispatcherTimer = executor.timer
If enable AndAlso Not timer.IsEnabled Then
timer.Start()
ElseIf Not enable AndAlso Not timer.IsEnabled Then
timer.Stop()
End If
End Sub
Private Shared Sub OnIntervalUpdate(ByVal d As DependencyObject, ByVal e As DependencyPropertyChangedEventArgs)
Dim executor As RefreshBehavior = CType(d, RefreshBehavior)
Dim timer As DispatcherTimer = executor.timer
timer.Interval = CType(e.NewValue, TimeSpan)
End Sub
Private WithEvents attachedObject As FrameworkElement
Private Sub OnUnload(ByVal sender As Object, ByVal e As EventArgs) Handles attachedObject.Unloaded
timer.Stop()
End Sub
Private attached As Boolean = False
Protected Overrides Sub OnAttached()
attached = True
attachedObject = AssociatedObject
If Enabled Then timer.Start()
MyBase.OnAttached()
End Sub
Protected Overrides Sub OnDetaching()
timer.Stop()
attached = False
attachedObject = Nothing
MyBase.OnDetaching()
End Sub
Private Sub OnTick(ByVal sender As Object, ByVal e As EventArgs) Handles Timer.Tick
Dim cmd = Command
Dim parameter = CommandParameter
If Interval < TimeSpan.MaxValue AndAlso cmd IsNot Nothing AndAlso cmd.CanExecute(parameter) Then
cmd.Execute(parameter)
End If
End Sub
End Class
End Namespace
You can use it like this:
<i:Interaction.Behaviors>
<Behaviors:RefreshBehavior Enabled="True" Interval="0:0:10" Command="{Binding RefreshPageCommand}" />
</i:Interaction.Behaviors>
I hope it helps someone with a similar problem.

Resources