About the author

Brian Keating is a developer addicted to Microsoft Technologies.

Month List

RecentComments

Comment RSS

MVC Binding restriction

clock October 11, 2010 05:56 by author Brian Keating |

There are a few options when restricting what properties of a type get automatically bound by the framework.

Take the Loler type seen in my other MVC2 blog posts.

[Bind(Include="ID,Name,Description")]
public class Loler
{  
//entity framework generated
}

Notice only the ID Name and Description properties will be bound by MVC Framework.

 

Per Usage restriction

UpdateModel(loler, new[] { "ID", "Name", "Description" });

Action method restrictions

[HttpPost]
ActionResult Create([Bind(Include="ID,Name,Description")] Loler loler)
{
// implementation
}




WPF ListViewItem Commands with MVVM pattern

clock May 12, 2010 19:44 by author Brian Keating |

If you're interested to see how to attach commands to listview items for use with an implementation of the MVVM pattern, have a look at this.

 

<Style x:Key="Local_OpenEntityStyle"
           TargetType="{x:Type ListViewItem}">
        <Setter Property="acb:CommandBehavior.Event"
                        Value="MouseDoubleClick" />
        <Setter Property="acb:CommandBehavior.Command"
                        Value="{Binding ElementName=uiEntityListDisplay, Path=DataContext.OpenEntityCommand}" />
        <Setter Property="acb:CommandBehavior.CommandParameter"
                        Value="{Binding}" />
</Style>

 

Here the command to be fired on the MouseDoubleClick event is set, the CommandParameter, will be the data object that we click on.