Share via


TPropertyBag.SetValue(const WCHAR *,XRValue *) (Compact 2013)

3/28/2014

This method sets a new value for a data source property in the property bag.

Syntax

HRESULT STDMETHODCALLTYPE SetValue(
const WCHAR * PropertyName,
XRValue * pValue)

Parameters

  • PropertyName
    [in] Name of the property.
  • pValue
    [in] Pointer to an XRValue object that contains the new value for the property.

Return Value

The following table shows the possible return values.

Value

Description

S_OK

The method was successful.

E_FAIL

The method was unable to find an iXRPropertyBinding object in m_PropertiesMap by using the property name in the PropertyName parameter.

E_POINTER

The pValue parameter is not valid.

Remarks

To support dynamic data in a data source object, call the SetValue method to update values of properties in the property bag for the object.

You can bind property data to a UI element either by calling IXRFrameworkElement::SetBinding or by using a Binding Markup Extension in Microsoft Silverlight 3 XAML.

Example

The following code example uses the SetValue method to update the BSTR value of the Name property of a data source object represented by the m_DataObject variable, by using a text string of type LPWSTR.

Warning

For readability, the following code example does not contain security checking or error handling. Do not use the following code in a production environment.

#include "stdafx.h"
#include "XRPropertyBag"
#include "XamlRuntime.h"

XRPtr<EmailMessageDataClass> m_DataObject; 

void UpdateStringData()
{
     XRAutoCriticalSection csObject;
     
     // Define new data; for example, the value of the PR_SENDER_NAME property from CEMAPI.
     LPWSTR EmailSenderName = TEXT("Sanjay Patel");
     
     // Define a critical section object. 
      EnterCriticalSection(&csObject);    
      
     // Allocate and set a new BSTR for the email sender name.
     XRValue updatedxrvalue;
     updatedxrvalue.bstrStringVal = SysAllocString(EmailSenderName);
     updatedxrvalue.vType = VTYPE_BSTR;
               
     // Update the property value.
     m_DataObject->SetValue(L"Name", &updatedxrvalue);     
    
     // Release the critical section object.        
      LeaveCriticalSection(&csObject);

}

Requirements

Header

XRPropertyBag.h

See Also

Reference

TPropertyBag<Derived>
TPropertyBag.GetValue(const WCHAR *,XRValue *)