hello. I am using XamDataGrid with user information. This page can only be viewed by administrators, and only administrators can edit information. The field has a password and I want to make this password invisible.Ex) password : ***************I'm use MaskedTextField but, can't edit Fieldtext. this is my xaml.<igWPF:MaskedTextField Name="user_pw" Label="Password" Width="*" Mask="******"/>When I use Mask="*******", the text is invisible. but, the text cannot be edited.Can I make only the text invisible while keeping the content as it is?
It works too! many thanks!
Hello Kim,
I'm glad I was able to help.
I would like to share two alternative solutions. It might be better to just handle the InitializeRecord event and look for e.Record to be a GroupByRecord and set the Description there. It could be done with the following code:
private void XamDataGrid1_InitializeRecord(object sender, Infragistics.Windows.DataPresenter.Events.InitializeRecordEventArgs e) { if (e.Record is GroupByRecord) { int endIndex = e.Record.Description.IndexOf(" "); if (endIndex >= 0) e.Record.Description = e.Record.Description.Substring(0, endIndex); } }
Alternatively, if you want to change that for the entire app you could also change the resource strings we use to format that, which is GroupByDescription_Format_NotOneChild and GroupByDescription_Format_OneChild. See the docs for more on the resource strings:
https://ko.infragistics.com/help/wpf/resource-strings-datapresenter-resource-strings
Regards,Ivan Kitanov
Thank you very very much! You are my savior
It seems that I have misunderstood you. If you would like to present a field inside the XamDataGrid as a password field and hide the value out of edit mode, then I recommend you using a converter that takes the password value and returns it as string of “*”. The converter should be similar to the code below:
public class TextToPasswordConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { ValueEditor editor = parameter as ValueEditor; DataRecord record = editor.DataContext as DataRecord; var password = record.Cells["Password"].Value; var dataGrid = (XamDataGrid)Infragistics.Windows.Utilities.GetAncestorFromType(editor, typeof(XamDataGrid), false); string passValue = ""; for (int i = 0; i < password.ToString().Length; i++) { passValue = passValue + "*"; } return passValue; } public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { return value; }
Additionally, inside the XAMl you would need to use a Style that targets the XamTextEditor and set its ValueToDisplayTextConverter property to the converter it could be done with the following XAML:
<Window.Resources> <l:TextToPasswordConverter x:Key="converter" /> </Window.Resources> <Grid> <igWPF:XamDataGrid x:Name="xamDataGrid1"> <igWPF:XamDataGrid.FieldLayouts> <igWPF:FieldLayout> <igWPF:Field Name="ID" Label="ID"/> <igWPF:Field Name="Name" Label="Name"/> <igWPF:Field Name="Date" Label="Date"/> <igWPF:Field Name="Password" Label="Password"> <igWPF:Field.Settings> <igWPF:FieldSettings> <igWPF:FieldSettings.EditorStyle> <Style TargetType="{x:Type igEditors:XamTextEditor}"> <Setter Property="ValueToDisplayTextConverter" Value="{StaticResource converter}"/> </Style> </igWPF:FieldSettings.EditorStyle> </igWPF:FieldSettings> </igWPF:Field.Settings> </igWPF:Field> </igWPF:FieldLayout> </igWPF:XamDataGrid.FieldLayouts> </igWPF:XamDataGrid> </Grid>
I am attaching a small sample application that demonstrates what I have explained above, please test it on your side and let me know if you have any questions.
Regards, Ivan Kitanov
PasswordFieldXamDataGrid.zip
It doesn't even have to be MaskedTextField. Even if it is simply a Field, only the content needs to be hidden.