Hello,
I am using Xamgrid in our project. We have requirement like below :-
once user double click one of the specific column ( large comment details column) , one new window will open as a dialog with one big Textbox , ok and cancel button. User will able to view whole commnet in this dialog in the textbox and also if IsEditable property is true, then they can also able to edit it in the same textbox.
And we need this type of column behavior in number of grids in our project. So I have created a custom column of XamGrid. and register the double click event in the column provider and open the new dailog. Everything works fine.
The problem is :- I am not able to bind IsEditable to the IsReadOnly property of column. So its always editable. :(
PFA for the dummy project to replicate the issue.
Once you run the project. you will 2 coulmns ID and Description. ID coulmn has tooltip which binds with the IsEditable property. So tooltip is different in different rows.
But the second column Description , once u double click , it will open a MessageBox with IsEditable property and its shows always false and then open my dialog box which is also editable for all rows As its not binded properly. :(
<ig:XamGrid ActiveItem="{Binding SelectedItem}" ItemsSource="{Binding TestItemSource}" AutoGenerateColumns="False" x:Name="XamGrid"> <ig:XamGrid.EditingSettings> <ig:EditingSettings AllowEditing="Row" IsMouseActionEditingEnabled="DoubleClick"></ig:EditingSettings> </ig:XamGrid.EditingSettings> <ig:XamGrid.Columns> <ig:TextColumn Key="Id" IsReadOnly="True" AllowToolTips="Always" x:Name="idKey"> <ig:TextColumn.ToolTipContentTemplate> <DataTemplate> <TextBlock Text="{Binding IsEditable}"></TextBlock> </DataTemplate> </ig:TextColumn.ToolTipContentTemplate> </ig:TextColumn>
<longTextColumnPoc:LongTextColumn Key="Description" IsReadOnly="{Binding IsEditable}"></longTextColumnPoc:LongTextColumn> </ig:XamGrid.Columns>
This binding in bold is not working.
Below is the model of my gird.
private BindingList<TestModel> _testItemSource = new BindingList<TestModel>(); public BindingList<TestModel> TestItemSource { get { return _testItemSource; }
set { _testItemSource = value; RaisePropertyChanged("TestItemSource"); } }
public class TestModel { public string Id { get; set; } public string Description { get; set; }
public bool IsEditable { get { if (Id == "1") return false; return true; } } }
I am just checking if you need any further assistance on the matter. If you do, please feel free to ask.
Hi neha24july,
The reason the binding doesn't work is because the LongTextColumn (or any XamGrid column) is not a part of the visual tree, therefore it does not have a DataContext to bind to. I recommend taking a different approach. Add an IsEditableMemberPath property to your column and then use reflection to get the IsEditable property from the row data. Inside your DoubleClick event you have access to the row data through the TextControl.DataContext. Then use reflection to get the IsEditable property and pass it to your popup window.
I have attached a modified version of your sample. Let me know if you have any questions on this.
Can some one help please...