SYSK 298: WPF: Control Whether a Grid’s Cell Is Editable in XAML

Say, you’re using a grid control to display some data, and you’re allowing users to modify data under certain circumstances.  Based on a business rule, you’d like to “lock” a certain record (i.e. make it read-only).


If you’re using data binding it’s quite straight forward.  In my example, I’m using an XML data source and a TextBox control to let users view/modify the data.  I use submitted XML data attribute to control whether the record should be editable or not:




            <TextBox Text="{Binding XPath=@type}" IsReadOnly="{Binding XPath=@submitted}" Width="100px"/>






Comments (0)

Skip to main content