Here's the scenario:
I have two controls: MainApp.xaml and a Popup.xaml (that contains a Silverlight popup control)
The MainApp.xaml has a Telerik Grid control (and I don't think this is Telerik specific) that binds to an ObservableCollection in the ViewModel. The ObservableCollection, as defined in the Model, has a few fields as defined below:
public
class
ProofOfPurchase
{
private
ChecksService.ProofOfPurchase _proofOfPurchase;
public
ChecksService.ProofOfPurchase Data
{
get
{
return
_proofOfPurchase;
}
set
{
_proofOfPurchase = value;
}
}
public
string
Name
{
get
{
if
(_proofOfPurchase.DebitRequest !=
null
)
return
_proofOfPurchase.DebitRequest.Consumer.Contact.FirstName +
" "
+ _proofOfPurchase.DebitRequest.Consumer.Contact.LastName;
else
return
string
.Empty;
}
}
public
string
Source
{
get
{
return
Enum.GetName(
typeof
(Enums.ProofOfPurchaseSourceEnum), _proofOfPurchase.SourceEnumId);
}
}
public
string
HoldCode
{
get
{
if
(!
string
.IsNullOrEmpty(_proofOfPurchase.HoldCode) && (Convert.ToInt32(_proofOfPurchase.HoldCode) > 0))
{
HoldCodes code = POPViewModel.HoldCodes.Where(h => h.CodeId.ToString() == _proofOfPurchase.HoldCode).Single();
return
code.CodeId +
" - "
+ code.Code;
}
else
return
string
.Empty;
}
}
}
The Data property is based on a WCF service. The other three properties are virtual properties for the view.
My grid columns look something like this (this is an extracted sample):
<
telerik:GridViewDataColumn
DataMemberBinding
=
"{Binding Path=Data.Id}"
Header
=
"POP ID"
UniqueName
=
"POPIP"
IsFilterable
=
"False"
/>
<
telerik:GridViewDataColumn
DataMemberBinding
=
"{Binding Path=Data.DateSubmitted}"
Header
=
"Date Submitted"
TextAlignment
=
"Right"
DataFormatString
=
"M/dd/yyyy"
UniqueName
=
"DateSubmitted"
IsFilterable
=
"True"
/>
<
telerik:GridViewDataColumn
DataMemberBinding
=
"{Binding Path=Data.ProofOfPurchaseStatus.Name}"
Header
=
"Status"
UniqueName
=
"Status"
IsFilterable
=
"True"
/>
<
telerik:GridViewDataColumn
DataMemberBinding
=
"{Binding Path=HoldCode}"
Header
=
"Hold Code"
UniqueName
=
"HoldCode"
IsFilterable
=
"True"
/>
<
telerik:GridViewDataColumn
DataMemberBinding
=
"{Binding Path=Source}"
Header
=
"Source"
UniqueName
=
"Source"
IsFilterable
=
"True"
/>
<
telerik:GridViewDataColumn
DataMemberBinding
=
"{Binding Path=Name}"
Header
=
"Pet Owner Name"
UniqueName
=
"OwnerName"
IsFilterable
=
"False"
/>
My problem is this:
In this popup, I'm able to change certain fields - ProofOfPurchaseStatus (column 3), Hold Code (column 4), and Source (column 5) being some of them. If I update the Status in the popup, the Grid is updated with the new status accordingly. However, if I update the HoldCode or the Source, the Grid view is not updated. The database is updated correctly, but the view, itself, isn't. I have to refresh my page to see the updated grid. Now, if I change the Hold Code Binding Path (column 4) to "Data.HoldCode" to see the underlying, non-calculated data of the field, the column's value is updated every time in the view. Only, when I'm using virtual properties does the view not realize there's a change.
NOTE: I also tried creating a separate method in the Model that executes in the Data property's Setter. The method would update all three virtuals. The virtuals, in this case, only returned private properties (i.e. the calculations were performed in the private method and the virtuals only returned values created/stored by the private method).
What am I missing? It seems like the View (and/or Grid) doesn't know that the virtual properties have changed even though the underlying data object has.
Thanks,
Joshua