我在基于下拉选择
更新数据网格内容时遇到了一个非常奇怪的场景我有一个组合框和一个数据网格,根据选定的组合框项目,网格内容将动态显示。
问题:最初,数据网格在加载时将为空。当我选择组合框项目时,相关数据将绑定到数据网格,但数据不会显示。当我调整窗口大小(反过来调整数据网格大小)时,将显示结果。
这是我的datagrid代码
<DataGrid Grid.Row="1"
Name="dgSchools"
Grid.ColumnSpan="2"
VerticalAlignment="Stretch"
Visibility="{Binding IsChecked, ElementName=rdSchools, Converter={StaticResource BooleanToVisibilityConverter}}"
AutoGenerateColumns="False"
Margin="0,5"
Background="White"
HeadersVisibility="Column"
ItemsSource="{Binding SchoolDetails}"
SelectedItem="{Binding SelectedSchoolDetail}"
Height="150"
HorizontalScrollBarVisibility="Hidden"
SelectionMode="Single"
CanUserAddRows="False"
CanUserSortColumns="True">
<DataGrid.Columns>
<DataGridTextColumn Header="Location" Binding="{Binding Location}"/>
<DataGridHyperlinkColumn Header="School Name" Width="3*" Binding="{Binding Name}" IsReadOnly="True">
<DataGridHyperlinkColumn.ElementStyle>
<Style>
<EventSetter Event="Hyperlink.Click" Handler="OnSchoolNameClick"/>
</Style>
</DataGridHyperlinkColumn.ElementStyle>
</DataGridHyperlinkColumn>
</DataGrid.Columns>
</DataGrid>
SchoolDetails
使用ReactiveUI
ReactiveList(Of School)
Private lstSchools As ReactiveList(Of School)
Public Property SearchResults() As ReactiveList(Of School)
Get
Return lstSchools
End Get
Set(value As ReactiveList(Of School))
Me.RaiseAndSetIfChanged(lstSchools, value)
End Set
End Property