I have a case where I need the rows of the grid to be smaller than the default height. When I set the cell max height to something like 20, there is plenty of space to show the text, but the bottom of the text gets cut off and there is empty space above the text (see image).
I have tried creating a CellValuePresenter and setting the margin and padding to 0, but that did not work. Is there a way to modify the spacing between rows?
John Myczek
Yes, I did have the theme set. Thank you again for you help.
John
John,
It is not a dumb question at all.
One thing that might have prevented your style from being picked up from a higher scope is if you set the 'Theme' property on the XamDataPresenter. The way the theme property works is that, when set, we inject a ResourceDictionary with the appropriate resources for that theme into the MergedDictionaries of the Resources of the XamDataPresenter. That way you can pick up the theme on the control but also override specific styles at the control level since directly set resources take precedence over MergedDictionaries.
Joe
Joe -
I installed the snoop utility (very cool) and the extra space was coming from the padding on the XamTextEditor. It turns out my style was not being picked up. I had the styles defined in my default resource dictionary. I moved them directly to the XamDataPresenter (<igDP:XamDataPresenter.Resources>) and it worked. Any idea why the styles would not be picked up from my default resource dictionary? Sorry if this is a dumb question, but I'm fairly new to WPF.
Thanks for your help,
Yes, the default template for CellValuePresenter contains a ContentPresenter with a name of "PART_EditorSite". We look for that name and if found will create an instance of a ValueEditor derived class suitable for editing the data type of the cell.
I'm not sure what is causing the records to be too tall in the build you have. The easiest way for you to find out is to run the Snoop utility (found at http://www.blois.us/Snoop/) and walk up the ancestor chain of elements from the lowest level editor element. If you look at the ActualHeight property it will identify the culprit(s).
Thanks Joe,
I added the style definitions that you posted, but it did not have any effect. I am not using the editors directly, are they automatically used? Here is the XAML for my grid:
<igDP:XamDataPresenter x:Name="currentAllocDSPPresenter" DataSource="{Binding Source={StaticResource ResourceAllocDspDS}}" AutoFit="False" HorizontalAlignment="Left" GroupByAreaLocation="None" Theme="Aero" >
<igDP:XamDataPresenter.FieldSettings>
<igDP:FieldSettings AllowEdit="False" AllowResize="False" CellContentAlignment="ValueOnly" CellClickAction="SelectRecord"/>
</igDP:XamDataPresenter.FieldSettings>
<igDP:XamDataPresenter.FieldLayoutSettings>
<igDP:FieldLayoutSettings AutoGenerateFields="False" DataRecordCellAreaStyle="{StaticResource readOnlyCellAreaStyle}" RecordSelectorLocation="None" HighlightAlternateRecords="True" />
</igDP:XamDataPresenter.FieldLayoutSettings>
<igDP:XamDataPresenter.FieldLayouts>
<igDP:FieldLayout Key="fieldLayout">
<igDP:FieldLayout.Fields>
<igDP:Field Name="DeviceName">
<igDP:Field.Settings>
<igDP:FieldSettings CellWidth="80" CellMaxHeight="20" />
</igDP:Field.Settings>
</igDP:Field>
<igDP:Field Name="G711">
<igDP:FieldSettings CellWidth="60" CellMaxHeight="20"/>
... other fields just like the ones above ...
</igDP:FieldLayout>
</igDP:XamDataPresenter.FieldLayouts>
</igDP:XamDataPresenter>