I have tried the following :
ScrollViewer.CanContentScroll=\"True\"
ScrollViewer.HorizontalScrollBarVisibility=\"Visible\"
But it does not seem
the below solution will work. since listbox width is set to datagrid width scroll bar will be visble.
<ScrollViewer HorizontalScrollBarVisibility="Auto" CanContentScroll="True">
<Grid>
<ListBox Width="{Binding ElementName=myGrid,Path=ActualWidth}"></ListBox>
<DataGrid Name="myGrid"></DataGrid>
</Grid>
</ScrollViewer>
There must be a possibility to do it, because Extended WPF Toolkit has done it!
Lets assume that you have e.g. this class:
public class ExampleClass
{
public int LongPropertyNameA;
public int LongPropertyNameB;
public int LongPropertyNameC;
public int LongPropertyNameD;
public int LongPropertyNameE;
public int LongPropertyNameF;
}
The normal approach looks like this:
The Headers are hidden.
The XAML Code looks e.g. like this:
<busGeneratorMvvm:CustomDataGrid ItemsSource="{Binding YourData}" IsReadOnly="True" />
When you use the WPT Toolkit DataGrid Library (called Xceed.Wpf.DataGrid.dll) the grid looks like this with the scrollbars you want:
The XAML Code looks e.g. like this:
<xcdg:DataGridControl ItemsSource="{Binding YourData}" >
where xcdg
is the namespace defined in the Window tag with this XAML Code:
<Window ...
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
...
>
Conclusion:
If you want it very easy download the Xceed WPF Toolkit and use the DataGridControl
.
DataGridControl
Hope it helps!