Hi folks,
I've got a problem occuring the XamDataGrid:
When using the Field Chooser or moving around the columns with the TextBlock in the label, either the label of the moved one, or all labels with TextBlock in it disappear and stay empty when using Field Chooser.
I need the textblock because of two loalization resources to display in some of my headers (adding name and unit for some of the labels)
Tested versions are 18.2.20182.186 and 19.1.20191.84, both contain the same behaviour.
Here is the XAML for an example:
<Window xmlns="">schemas.microsoft.com/.../presentation" xmlns:x="">schemas.microsoft.com/.../xaml" xmlns:d="">schemas.microsoft.com/.../2008" xmlns:mc="">schemas.openxmlformats.org/.../2006" xmlns:local="clr-namespace:WpfAppInfragisticsTest" xmlns:igDP="">infragistics.com/DataPresenter" xmlns:igEditors="">infragistics.com/Editors" x:Class="WpfAppInfragisticsTest.MainWindow" mc:Ignorable="d" Title="MainWindow" Height="450" Width="800"> <Grid> <igDP:XamDataGrid BindToSampleData="True"> <igDP:XamDataGrid.FieldSettings> <igDP:FieldSettings AllowFixing="Near" AllowEdit="False" AllowHiding="Always" AllowRecordFiltering="True" AllowLabelVirtualization="False" /> </igDP:XamDataGrid.FieldSettings> <igDP:XamDataGrid.FieldLayoutSettings> <igDP:FieldLayoutSettings HeaderPrefixAreaDisplayMode="FieldChooserButton" DataRecordSizingMode="SizedToContentAndIndividuallySizable" AllowRecordFixing="Top" AllowClipboardOperations="Copy" CopyFieldLabelsToClipboard="True" AutoGenerateFields="False" AutoFitMode="OnlyWithVisibleStarFields" /> </igDP:XamDataGrid.FieldLayoutSettings> <igDP:XamDataGrid.FieldLayouts> <igDP:FieldLayout> <igDP:FieldLayout.Fields> <igDP:Field Name="name" Label="name"/> <igDP:Field Name="department" Label="dep" /> <igDP:Field Name="salary"> <igDP:Field.Label> <TextBlock> <Run Text="A"/> <LineBreak/> <Run Text="B"/> </TextBlock> </igDP:Field.Label> </igDP:Field> <igDP:Field Name="email"> <igDP:Field.Label> <TextBlock> <Run Text="C"/> <LineBreak/> <Run Text="D"/> </TextBlock> </igDP:Field.Label> </igDP:Field> </igDP:FieldLayout.Fields> </igDP:FieldLayout> </igDP:XamDataGrid.FieldLayouts> </igDP:XamDataGrid> </Grid></Window>
Any idea on how to get it to work without the labels disappearing would be appreciated.
Thanks and greetings
Stefan
This is actually the expected behavior and isn't specific to us. Putting a TextBlock as the label. A TextBlock is a Visual and Visuals in WPF can (and will) only be displayed in 1 place. You'd see the same thing if you tried to have other wpf elements show this same "value". e.g.
<StackPanel><Button Background="Red" x:Name="btnRed"><TextBlock><Run Text="C"/><LineBreak/><Run Text="D"/></TextBlock></Button><Button Background="Blue"Content="{Binding ElementName=btnRed, Path=Content}"/>
</StackPanel>
To work around this you need to either set the Label to a string with the new lines in it (e.g.
<ig:Field Name="salary" Label="A&x0a;B"/> ) or set it to a Binding that binds to something that provides the information (e.g. bind to a property on their view model or use a MultiBinding and combine info from multiple pieces potentially using a custom IValueConverter if needed) or if they really need complex structure then they likely need to retemplate the LabelPresenter but I would suggest ensuring that the Label property of the field is ultimately a string (directly or via a binding) since that will be used for some things that need text like when we export to excel/word or when one does a copy/paste where headers are included.
Was this ever fixed? I think we are running into the same problem .
Hello Mike,
Thank you for contacting Infragistics!
I have logged this for further investigation with the ID 263868. I have also created a private case where I will provide you with more information.