I was trying to add Close button for calendar, to have possibility of closing it not only when user clicks outside the scope of calendar. I got style file and the file which control date picker (got there method like DatePicker_DropDownOpened, which works very well). So I know how to hide it -> e.x.
datePicker.Visibility = Visibility.Visible; or (like described here
http://www.telerik.com/help/silverlight/raddatetimepicker-how-to-hide-show-pop-up-in-code.html)
this.radDateTimePicker.IsDropDownOpen = true;
The problem is how to make relation beetwen button and code. So I've tried this (only using XAML style file):
<Button x:Name="CloseButton" Content="Close" Width="Auto" Margin="0">
<i:Interaction.Triggers
>
<
i:EventTrigger
EventName
=
"Click"
>
<
ei:ChangePropertyAction
TargetName
=
"DropDownPopupContent"
PropertyName
=
"Visibility"
Value
=
"Collapsed"
/>
</
i:EventTrigger
>
</
i:Interaction.Triggers
>
</Button>
So it perfectly hides the date picker when I click on it, but it doesn't show again (probably because control change ActualWidth and ActualHeight property and not Visibility). Changing IsOpen property in that way has no effect at all.
I've tried also binding it to command:
<
Button
x:Name
=
"CloseButton"
Content
=
"Close"
Width
=
"Auto"
Margin
=
"0"
>
<
i:Interaction.Triggers
>
<
i:EventTrigger
EventName
=
"Click"
>
<
i:InvokeCommandAction
Command
=
"{Binding HideCalendarCommand}"
/>
</
i:EventTrigger
>
</
i:Interaction.Triggers
>
</
Button
>
While the command is registered inside OnApplyTemplate method
HideCalendarCommand =
new RelayCommand(() =>
{
datePicker.Visibility =
Visibility.Collapsed;
});
then there is no effect when I click on the button (probably because it's a style file, no?)
I'm quite new in Silverlight world, so any help would be welcomed :)