I'm using custom appointments in a grouped schedule view, with a custom template where the background color depends on properties from the custom appointments. It works fine, however when i create / edit appointments, the background color changes incorrectly without passing through the converter.
Here is the AppointmentTemplate i use
And the corresponding converter
When i create an appointment, the converter seems to receive in its value the rightmost appointment (at least that's what it looks like)
I have uploaded a flv movie of the behavior here: http://api.ge.tt/0/9XB2KQ8/0/blob/download
It would have been nice to upload it on your forums but even changing the extension didn't work :)
Here is the AppointmentTemplate i use
<
DataTemplate
x:Key
=
"PlanificationTemplate"
>
<
Border
Background
=
"{Binding Converter={StaticResource PrestationTypeConverter}}"
>
<
StackPanel
>
<
StackPanel
Orientation
=
"Horizontal"
>
<
TextBlock
Text
=
"{Binding Subject}"
FontWeight
=
"Bold"
TextWrapping
=
"Wrap"
/>
<
TextBlock
FontWeight
=
"Bold"
> - (</
TextBlock
>
<
TextBlock
Text
=
"{Binding Appointment.Planification.Prestation.Produit}"
FontWeight
=
"Bold"
TextWrapping
=
"Wrap"
/>
<
TextBlock
FontWeight
=
"Bold"
>)</
TextBlock
>
</
StackPanel
>
<
StackPanel
Orientation
=
"Horizontal"
>
<
TextBlock
>Site: </
TextBlock
>
<
TextBlock
Text
=
"{Binding Appointment.Planification.Prestation.Site}"
FontWeight
=
"Bold"
TextWrapping
=
"Wrap"
/>
</
StackPanel
>
<
StackPanel
Orientation
=
"Horizontal"
>
<
TextBlock
>De </
TextBlock
>
<
TextBlock
Text
=
"{Binding Start, StringFormat=\{0:HH:mm\}}"
TextWrapping
=
"Wrap"
/>
<
TextBlock
> à </
TextBlock
>
<
TextBlock
Text
=
"{Binding End, StringFormat=\{0:HH:mm\}}"
TextWrapping
=
"Wrap"
/>
</
StackPanel
>
</
StackPanel
>
</
Border
>
</
DataTemplate
>
public
class
PrestationTypeConverter: IValueConverter
{
public
object
Convert(
object
value, Type targetType,
object
parameter, System.Globalization.CultureInfo culture)
{
PlanificationAppointment v =
null
;
var vaip = value
as
AppointmentItemProxy;
if
(vaip !=
null
)
{
v = vaip.Appointment
as
PlanificationAppointment;
}
else
{
v = value
as
PlanificationAppointment;
}
if
(v !=
null
)
{
return
ConvertPrestationTypeToColor.Convert(v.Planification.Prestation); // this is a Dictionnary type -> color
}
else
{
return
new
SolidColorBrush(Color.FromArgb(255, 42, 156, 24));
}
}
public
object
ConvertBack(
object
value, Type targetType,
object
parameter, System.Globalization.CultureInfo culture)
{
throw
new
NotImplementedException();
}
}
When i create an appointment, the converter seems to receive in its value the rightmost appointment (at least that's what it looks like)
I have uploaded a flv movie of the behavior here: http://api.ge.tt/0/9XB2KQ8/0/blob/download
It would have been nice to upload it on your forums but even changing the extension didn't work :)