0

i try to show the user some not so important columns of my datagrid, only when enough space(width of the whole program) available is. so i wanna bind the visibility of the column to the actual with of the datagrid with a converter. all of my converters, who i wrote works well, BUT in this case happens nothing, means there is no call of the converter. i checked that out by my debug log.

<mui:DataGridTextColumn Header="Kilometer" 
                        MinWidth="20" 
                        Width="SizeToCells"
                        Binding="{Binding Path=Kilometer, TargetNullValue='-', FallbackValue='-'}"  
                        Visibility="{Binding Path=ActualWidth, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type DataGrid}}, TargetNullValue=Collapsed, FallbackValue=Collapsed, Converter={StaticResource IntAsLimit2VisibilityCollapsed}, ConverterParameter=1300}"
                        />

made i something wrong? is it maybe in this combination not possible?

René Hankel
  • 53
  • 2
  • 6

1 Answers1

0

As stated here, DataGrid columns don't lie in Visual tree of DataGrid, and we can't get to outer DataContext using RelativeSource. We can only use x:Reference to an external FrameworkElement.

Also, here is a similar question with a possible solution (you don't need to set a width and will probably avoid a circular reference).

Community
  • 1
  • 1
mechanic
  • 761
  • 6
  • 11
  • thx a lot i did not found these links. :/ but know i remember: this proxy story, but one thing IS interesting, because that works: – René Hankel Nov 16 '16 at 19:53