开发者

How to disable button in datagridrow in wpf programmatically

I had placed datagrid populating data from databa开发者_运维知识库se.

Now I had kept button in all row using datagridcolumntemplate and datatemplate

I want to disable button of last column for first two rows.


I would create a View Model to wrap the database data into Objects and add an extra property to them: IsVisible.

Then inside your data template you can set the binding of the Button to :

<Button Visibility="{Binding Path=MyObject.IsVisible, 
        Converter={BooleanToVisibiltyConverter}}"/>

Maybe not the most elegant solution, but at least you don't mess with code behind. Also, I'm not sure if you can get the Row Collection of your grid using another approach.

HTH

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜