This project is read-only.

Value produced by BindingExpression is not valid for target property

Feb 1, 2013 at 2:57 PM
When scrolling horizontally in a DataGrid in a RibbonWindow, e.g. like this:

<ribbon:RibbonWindow x:Class="WpfApplication1.MainWindow"
Width="300" Height="300">
    <DataGrid HeadersVisibility="Column">
            <TextBlock Text="bla"/>
            <DataGridTextColumn Width="1000" />

I get a lot of errors like this:

System.Windows.Data Error: 5 : Value produced by BindingExpression is not valid for target property.; Value='-0.161290322580385' BindingExpression:Path=CellsPanelHorizontalOffset; DataItem='DataGrid' (Name='datagrid'); target element is 'Button' (Name=''); target property is 'Width' (type 'Double')

This only happens in a RibbonWindow, not in a normal non-Ribbon Window.

Any idea what's going on?

(The ItemsPresenter in the DataGrid's controltemplate seems to round it's position to integers when in a RibbonWindow for some reason.)
Feb 14, 2013 at 12:55 PM
Apparently this is triggered by setting UseLayoutRounding to true in RibbonWindow's style.

It seems one can avoid the problem by disabling it again for the DataGrid:
<DataGrid UseLayoutRound="False" ...

The DataGrid does seem to be rendered a bit blurrier though.
Feb 15, 2013 at 10:19 PM
I will change the code, so it does not set UseLayoutRound="True" on the window-level anymore, but at ribbon-level instead.
If someone wants this activated they have to do it in their project.
Again i think we shouldn't mess around with WPFs default values of DisplayMode, LayoutRound etc. in a control library.