Ejemplo n.º 1
0
        private TokenItem CreateTokenItem(Token token)
        {
            object item = token.Item;

            var tokenItem = new TokenItem()
            {
                TokenKey        = token.TokenKey,
                Content         = item,
                ContentTemplate = TokenTemplate
            };

            if (TokenTemplate == null)
            {
                //if no template was supplied let's try to get a value from the object using the DisplayMemberPath
                if (!String.IsNullOrEmpty(DisplayMemberPath))
                {
                    var property = item.GetType().GetProperty(DisplayMemberPath);
                    if (property != null)
                    {
                        var value = property.GetValue(item, null);
                        if (value != null)
                        {
                            tokenItem.Content = value;
                        }
                    }
                }
            }

            return(tokenItem);
        }
    private TokenItem CreateTokenItem( Token token )
    {
      object item = token.Item;

      var tokenItem = new TokenItem()
      {
        TokenKey = token.TokenKey,
        Content = item,
        ContentTemplate = TokenTemplate
      };

      if( TokenTemplate == null )
      {
        //if no template was supplied let's try to get a value from the object using the DisplayMemberPath
        if( !String.IsNullOrEmpty( DisplayMemberPath ) )
        {
          var property = item.GetType().GetProperty( DisplayMemberPath );
          if( property != null )
          {
            var value = property.GetValue( item, null );
            if( value != null )
              tokenItem.Content = value;
          }
        }
      }

      return tokenItem;
    }