WPF - Checkbox in cell row readonly possible? -


i have listview bind dynamically list of object of same type.

the object have boolean value.

there listview column display checkbox instead of "true" , "false" normal value specific property.

is there way set checkbox readonly ? otherwise there way tell click coming specific row in events "checked" , "unchecked" execute method in code behind ?

thanks!

you can make control readonly setting ishittestvisible , focusable false.

xaml:

<window x:class="wpfapplication1.window1"     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"     xmlns:wpfapplication1="clr-namespace:wpfapplication1">      <stackpanel>         <listview itemssource="{binding}">             <listview.view>                 <gridview>                     <gridviewcolumn header="name" displaymemberbinding="{binding path=name}" />                     <gridviewcolumn header="is valid">                         <gridviewcolumn.celltemplate>                             <datatemplate>                                 <checkbox ischecked="{binding path=isvalid}" ishittestvisible="false" focusable="false" />                             </datatemplate>                         </gridviewcolumn.celltemplate>                     </gridviewcolumn>                  </gridview>             </listview.view>         </listview>     </stackpanel>  </window> 

code behind:

using system.collections.generic;  namespace wpfapplication1 {     public partial class window1     {         public window1()         {             initializecomponent();              list<dataitem> data = new list<dataitem>();             data.add(new dataitem() { name = "aaa", isvalid = true });             data.add(new dataitem() { name = "bbb" });             datacontext = data;         }          public class dataitem         {             public string name { get; set; }             public bool isvalid { get; set; }         }     } } 

Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -