私の問題はこれに似ています。
行の詳細が、それがまたがる列の幅を超えないようにしたい場合を除きます。
|--0--|--1--|--2--|--3--|--4--|
|---------Row-Details---------|
私は試しAreRowDetailsFrozen
ましたが、これは効果がありませんでした。親グリッドの実際の幅(OneWay)にもバインドしようとしましたが、これにより、幅が2つの画面の幅を超えてしまいます。
これが私の現在の試みです(簡略化)。
<Grid>
<DataGrid x:Name="Grid"
Grid.Row="1"
ItemsSource="{Binding Collection}"
IsReadOnly="True"
AutoGenerateColumns="False"
ColumnWidth="Auto"
CanUserResizeColumns="False"
CanUserResizeRows="False"
RowDetailsVisibilityMode="VisibleWhenSelected"
AreRowDetailsFrozen="True"
SelectionUnit="FullRow"
VerticalAlignment="Top"
HorizontalAlignment="Center">
<DataGrid.RowDetailsTemplate>
<!-- Begin row details section. -->
<DataTemplate>
<TextBox DataContext="{Binding ErrorMessage}"
IsReadOnly="True"
Margin="5"
BorderBrush="Transparent"
ScrollViewer.VerticalScrollBarVisibility="Auto"
ScrollViewer.CanContentScroll="True"
TextWrapping="Wrap"
Text="{Binding .}">
</TextBox>
</DataTemplate>
</DataGrid.RowDetailsTemplate>
</DataGrid>
</Grid>
これにより、次のようになります。
|--0--|--1--|--2--|--3--|--4--|
|---------Row-Details are as wide as the longest row in their content ---------|
TextBoxの幅を任意の親コンテナ(Grid、DataGrid、ItemsPresenter)にバインドします。
Width="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Grid}}, Path=ActualWidth, Mode=OneWay}"
結果:
|------Viewable Area-------|
|---- Columns ----|
|---------Row-Details --------------------------------------------------------------|
非常にイライラします。行の詳細でDataGridの幅を変更しないようにしたいのですが、それだけ質問する必要がありますか?:)