私は、WPFデータグリッドを持っていると私はすべてのセルにテキストの折り返しを適用したいので、私はこのスタイル定義しました:DataGridのデータバインディング問題
<DataGrid.CellStyle>
<Style TargetType="DataGridCell">
<Setter Property="ContentTemplate">
<Setter.Value>
<DataTemplate>
<TextBlock TextWrapping="Wrap" FontSize="15" Text="{Binding}" VerticalAlignment="Center"
HorizontalAlignment="Center" ></TextBlock>
</DataTemplate>
</Setter.Value>
</Setter>
</Style>
</DataGrid.CellStyle>
<DataGrid.Columns>
<DataGridTextColumn Header="Name" Binding="{Binding Name}" Width="95" />
<DataGridTextColumn Header="Address" Binding="{Binding Address}" Width="95" />
<DataGridTextColumn Header="Category" Binding="{Binding Category}" Width="95" />
</DataGrid.Columns>
を、私は私のコードで私のDataGridののItemsSourceを設定しました背後にあるこのような:
myDataGrid.ItemsSource= new Customers[]
{
new ComputerStandard{Name="Michael Thomas",Address="16 Greenville Avenue",Category="A"},
new ComputerStandard{Name="Fiona Thompson",Address="19 Wright Street",Category="F"},
new ComputerStandard{Name="Jack Smith",Address="133 Kensington Road",Category="B"},
new ComputerStandard{Name="Michael jackson",Address="11 Wine Street",Category="C"},
new ComputerStandard{Name="Jerry Holmes",Address="10 Awson Street",Category="G"},
new ComputerStandard{Name="David Philips",Address="Not Specified",Category="A"}
};
しかし、どこかで何かが、私は自分のスタイルText="{Binding}"
に設定私のバインディング式で失敗し、私はで終わる:
明らかにバインディング式Text="{Binding}"
は失敗しています。私がこのスタイルを削除すると、すべてが完全に機能するためです。これを修正するにはどうすればいいですか?
ありがとうございます。