problem with ObjectDataProvider inside DataTemplate
-
I have to Bind to Method inside DataTemplate for ListBoxItem so I need to use ObjectDataProvider to determine the Method name and ofcourse the ObjectInstance will be the Object that is bound to the List Box Item that will use this template But How can I tell the Provider [In xaml] to use the bound object as Object Instatnce :confused: I tried the following code but Compiler error I got :((
<DataTemplate x:Key="ListBoxItemTemplate" > <DataTemplate.Resources> <ObjectDataProvider x:Key="CurrentRoomStateProvider" ObjectInstance={Binding } MethodName="GetRoomStateForSpecificDay" > <ObjectDataProvider.MethodParameters> <sys:DateTime>10-30-2009</sys:DateTime> </ObjectDataProvider.MethodParameters> </ObjectDataProvider> <ObjectDataProvider x:Key="CurrentRoomBookingWaitingsProvider" ObjectInstance={Binding } MethodName="GetBookingsWaitingForSpecificDay" > <ObjectDataProvider.MethodParameters> <sys:DateTime>10-30-2009</sys:DateTime> </ObjectDataProvider.MethodParameters> </ObjectDataProvider> </DataTemplate.Resources> <Border BorderBrush="#FFA69FEC" BorderThickness="2" Height="143" Width="123" > <Grid Width="120" Margin="0,0,0,0" VerticalAlignment="Top" Height="140" HorizontalAlignment="Right"> <GroupBox Margin="3.89,27,3.205,52.89" Header="Room Detail :"> <Grid> <TextBlock Margin="2.863,3.205,0,0" Text="Floor :" TextWrapping="Wrap" HorizontalAlignment="Left" Width="33.33" VerticalAlignment="Top" Height="18.57"/> <TextBlock Margin="2.863,21.775,0,0" Text="Type :" TextWrapping="Wrap" HorizontalAlignment="Left" Width="33.33" VerticalAlignment="Top" Height="21.375"/> <TextBlock Text="{Binding Path=FloorName}" ToolTip="{Binding Path=FloorName}" VerticalAlignment="Top" Height="14.57" Margin="40.193,3.205,8,0"/> <TextBlock Text="{Binding Path=RoomTypeName}" ToolTip="{Binding Path=RoomTypeName}"