Hello All,
I am trying to add a button in RadWinodw Title bar using its HeaderTemplate. Although button is visible on Title but its command is not properly binding and getting following error in Output window.
BindingExpression path error: 'SaveCommand' property not found on 'object' ''String' (HashCode=1384875945)'. BindingExpression:Path=SaveCommand; DataItem='String' (HashCode=1384875945); target element is 'Button' (Name=''); target property is 'Command' (type 'ICommand')
Here is my XAML portion.
Here is my SaveCommand property in my ViewModel object.
And here is how I am creating view and assigning its DataContext.
Kindly note that when I am placing this button in Window Content section, then Command binding is working fine.
I have also tried to set its RelativeSource using following code
But still it does not work.
Any help please.
I am trying to add a button in RadWinodw Title bar using its HeaderTemplate. Although button is visible on Title but its command is not properly binding and getting following error in Output window.
BindingExpression path error: 'SaveCommand' property not found on 'object' ''String' (HashCode=1384875945)'. BindingExpression:Path=SaveCommand; DataItem='String' (HashCode=1384875945); target element is 'Button' (Name=''); target property is 'Command' (type 'ICommand')
Here is my XAML portion.
<
telerik:RadWindow.HeaderTemplate
>
<
DataTemplate
>
<
StackPanel
Orientation
=
"Horizontal"
>
<
Button
x:Name
=
"btn"
Content
=
"button"
Command
=
"{Binding Path=SaveCommand}"
/>
</
StackPanel
>
</
DataTemplate
>
</
telerik:RadWindow.HeaderTemplate
>
Here is my SaveCommand property in my ViewModel object.
private
DelegateCommand _saveCommand;
public
ICommand SaveCommand
{
get
{
if
(_saveCommand ==
null
)
_saveCommand =
new
DelegateCommand(param => SaveIndicator(), param => CanSaveIndicator());
return
_saveCommand;
}
}
public
void
SaveIndicator()
{
}
protected
bool
CanSaveIndicator()
{
if
(eAppState == AppState.Fresh)
return
false
;
return
true
;
}
InterpolatedIndicators.AddEditIndicators view =
new
InterpolatedIndicators.AddEditIndicators();
view.DataContext =
new
InterpolatedIndicators.AddEditIndicatorsViewModel();
view.Owner =
this
;
view.ShowDialog();
Kindly note that when I am placing this button in Window Content section, then Command binding is working fine.
I have also tried to set its RelativeSource using following code
<
Button
x:Name
=
"btn"
Content
=
"button"
Command
=
"{Binding Path=DataContext.SaveCommand, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}}"
/>
Any help please.