I'm using the XamDataGrid to display notes for some projects in my application. For some users it shouldn't be possible to edit these notes. I therefore used FieldSettings to bind the IsReadOnly-property to a property in my ViewModel. The problem however, is, that the IsReadOnly-property only works on the XamComboEditor, and not the XamTextEditor.
XamComboEditor-field:
<igDP:Field Name="NoteType" Label="Type">
<igDP:Field.Settings>
<igDP:FieldSettings EditorType="{x:Type igEditors:XamComboEditor}">
<igDP:FieldSettings.EditorStyle>
<Style TargetType="{x:Type igEditors:XamComboEditor}">
<Setter Property="DataContext" Value="{Binding ElementName=layoutRoot, Path=DataContext}"/>
<Setter Property="ItemsSource" Value="{Binding NoteTypes}" />
<Setter Property="DisplayMemberPath" Value="Name" />
<Setter Property="ValuePath" Value="NoteTypeId" />
<Setter Property="IsReadOnly" Value="{Binding M.AccessReadOnly}" />
</Style>
</igDP:FieldSettings.EditorStyle>
</igDP:FieldSettings>
</igDP:Field.Settings>
</igDP:Field>
XamTextEditor-field:
<igDP:Field Name="NoteText" Label="" Width="*">
<igDP:FieldSettings EditorType="{x:Type igEditors:XamTextEditor}">
<Style TargetType="{x:Type igEditors:XamTextEditor}">
The IsReadOnly-property works just fine if I set it to false in the XAML. But when I use databinding it doesn't...
Hello Christian,
Thank you for your post. I have been looking through it and the code you have provided and I suggest you change the Binding in the XamTextEditor to the following one:
<Setter Property="IsReadOnly" Value="{Binding DataItem.M.AccessReadonly}" />
Because the DataContext there is DataRecord. Please let me know if this helps you or you need further clarifications on this matter.
Looking forward for your reply.
Hello Stefan
Thanks for your reply!
I tried the code you provided, but it still doesn't work.
The M.AccessReadOnly-property is only present in the DataContext for the Window and not in the actual DataItem (Note-object). I tried using layoutRoot instead.
This didn't work either!
I know that the property is set to false, because it works on the ComboBox!
I have attached a sample project that "contains" the same problem as my actual project.
Looking forward to hearing from you...
Hello,
I have been looking through the sample you have provided and I modified it, so now it works as you expected. Basically I changed the Binding in your XamTextEditor.
Hope this helps you.
I have another question regarding this issue.
How do I set the IsReadOnly-property on the XamTextEditor using a boolean property from the DataItem in the XamDataGrid. I can't quite figure out the syntax for the binding...
I have another question relating to xamtexteditor ,actually i have requirement to make the xamtexteditor readonly false means in edit mode when i click the contextmenu remove menu for tabitem item then only the xamtexteditor in that tab should be in edit mode below is my sample
<Window x:Class="WpfApplication3.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:ing="clr-namespace:Infragistics.Controls.Menus;assembly=InfragisticsWPF4.Controls.Menus.XamDataTree.v11.2" xmlns:igEditors="http://infragistics.com/Editors" xmlns:igWindows="http://infragistics.com/Windows" Title="MainWindow" Height="350" Width="525">
<Grid> <DockPanel> <igWindows:XamTabControl Background="AliceBlue" BorderBrush="AliceBlue" Name="SimTabControl"> <igWindows:XamTabControl.ItemContainerStyle> <Style TargetType="{x:Type igWindows:TabItemEx}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type igWindows:TabItemEx}"> <Grid SnapsToDevicePixels="true" Name="grdedit1"> <Border Name="Bdedit" Padding="{TemplateBinding Padding}" BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}" BorderThickness="1,1,1,0" CornerRadius="3,3,0,0"> <Grid Name="grdedit2"> <!--Substitute the ContentPresenter with a XamTextEditor--> <igEditors:XamTextEditor x:Name="txtedit" BorderThickness="0" Background="Transparent" Value="{Binding Header, RelativeSource={RelativeSource TemplatedParent}}" IsReadOnly="{Binding ElementName=txtedit, Path=DataContext.IsRO}"> <igEditors:XamTextEditor.ContextMenu> <ContextMenu Name="tabContextMenu"> <MenuItem Header="Rename" Click="MenuItem_Click"></MenuItem> </ContextMenu> </igEditors:XamTextEditor.ContextMenu> </igEditors:XamTextEditor> </Grid> </Border> </Grid> </ControlTemplate> </Setter.Value> </Setter> </Style> </igWindows:XamTabControl.ItemContainerStyle> </igWindows:XamTabControl> </DockPanel> </Grid></Window>
I have created a sample project for you with the functionality you want.
It seems like that I am missing something about your scenario, so if this is still an issue for you, could please be more specific what is the functionality you want to achieve and send me screenshots of the desired result.
hi,
I want to display the baloon message for XamTextEditor can u please share some sample
I am not aware of an EventBinding in WPF and I don’t think there is some approach for this functionality, but if you send me an article I could be able to think of a possible solution for you.
can you please tell me that hoew can we bind for lotfocus event of xamtexteditor like
<igEditors:XamTextEditor x:Name="txtedit" VerticalAlignment="Top" Text="TextBox Text" IsReadOnly="True" LostFocus="{Binding LostFocus}">
I have used Command for the MenuItem, so now there is no code behind.