---
title: "Interface IViewModelBinder"
slug: "sitecore.aspnet.renderingengine.binding.iviewmodelbinder"
abstract: ""
---
# Interface IViewModelBinder

Contract that allows models to be bound based on a Microsoft.AspNetCore.Mvc.Rendering.ViewContext.

## **Namespace**: Sitecore.AspNet.RenderingEngine.Binding

### **Assembly**: Sitecore.AspNet.RenderingEngine.Abstractions.dll

#### Syntax

```csharp
public interface IViewModelBinder

```

### Methods

#### Bind(Object, ViewContext)

Binds properties on the given `model` based on the given `viewContext`.

##### Declaration

```csharp
Task Bind(object model, ViewContext viewContext)

```

##### Parameters

| Type | Name | Description |
| --- | --- | --- |
| System.Object | model | The instance type to be returned. |
| Microsoft.AspNetCore.Mvc.Rendering.ViewContext | viewContext | The Microsoft.AspNetCore.Mvc.Rendering.ViewContext to bind against. |

##### Returns

| Type | Description |
| --- | --- |
| System.Threading.Tasks.Task | The instance of `model` with its properties updated. |

#### Bind(Type, ViewContext)

Binds properties on the given `modelType` based on the given `viewContext`.

##### Declaration

```csharp
Task<object> Bind(Type modelType, ViewContext viewContext)

```

##### Parameters

| Type | Name | Description |
| --- | --- | --- |
| System.Type | modelType | The instance type to be returned. |
| Microsoft.AspNetCore.Mvc.Rendering.ViewContext | viewContext | The Microsoft.AspNetCore.Mvc.Rendering.ViewContext to bind against. |

##### Returns

| Type | Description |
| --- | --- |
| System.Threading.Tasks.Task<br><br><<br><br>System.Object<br><br>> | The instance of `modelType` with its properties updated. |

#### Bind<TModel>(TModel, ViewContext)

Binds properties on the given `model` based on the given `viewContext`.

##### Declaration

```

Task Bind<TModel>(TModel model, ViewContext viewContext)
    where TModel : class

```

##### Parameters

| Type | Name | Description |
| --- | --- | --- |
| TModel | model | Ths instance to be bound. |
| Microsoft.AspNetCore.Mvc.Rendering.ViewContext | viewContext | The Microsoft.AspNetCore.Mvc.Rendering.ViewContext to bind against. |

##### Returns

| Type | Description |
| --- | --- |
| System.Threading.Tasks.Task | The instance of `model` with its properties updated. |

##### Type Parameters

| Name | Description |
| --- | --- |
| TModel | The instance type to be returned. |

#### Bind<TModel>(ViewContext)

Creates an instance of `TModel` and binds properties based on the given `viewContext`.

##### Declaration

```

Task<TModel> Bind<TModel>(ViewContext viewContext)
    where TModel : class, new()

```

##### Parameters

| Type | Name | Description |
| --- | --- | --- |
| Microsoft.AspNetCore.Mvc.Rendering.ViewContext | viewContext | The Microsoft.AspNetCore.Mvc.Rendering.ViewContext to bind against. |

##### Returns

| Type | Description |
| --- | --- |
| System.Threading.Tasks.Task<br><br><TModel> | A bound instance of `TModel` or default(`TModel`). |

##### Type Parameters

| Name | Description |
| --- | --- |
| TModel | The instance type to be returned. |
