Silverlight 页面内容大小基于浏览器大小
我得到的是一个 Page 类,其中包含:
<navigation:Page (...) Title="Import">
<Grid x:Name="LayoutRoot">
<ScrollViewer VerticalScrollBarVisibility="Auto"
HorizontalScrollBarVisibility="Auto"
Visibility="{Binding Visible}">
<c:BusyIndicator IsBusy="{Binding Busy}">
<StackPanel>
<StackPanel>
<Button/>
</StackPanel>
<Border Background="#c8c8c8" CornerRadius="5">
<sdk:DataGrid Name="myDataGrid" AutoGenerateColumns="False"
ItemsSource="{Binding Imports}" Margin="10" IsReadOnly="True">
<sdk:DataGrid.Columns>
<sdk:DataGridTextColumn Header="ID" Binding="{Binding ID}" Width=".3*"/>
<sdk:DataGridTextColumn Header="Name" Binding="{Binding Name}" Width=".7*"/>
</sdk:DataGrid.Columns>
</sdk:DataGrid>
</Border>
</StackPanel>
</c:BusyIndicator>
</ScrollViewer>
</Grid>
</navigation:Page>
我试图完成的是 DataGird 将始终具有最大可能的宽度和高度。它还应该固定最小宽度和高度。当浏览器小于DataGrid时,ScrollViewer应该启用滚动。我认为最小/最大宽度/高度属性将允许这种行为,但我无法让它工作。
What i have got is a Page class that contains:
<navigation:Page (...) Title="Import">
<Grid x:Name="LayoutRoot">
<ScrollViewer VerticalScrollBarVisibility="Auto"
HorizontalScrollBarVisibility="Auto"
Visibility="{Binding Visible}">
<c:BusyIndicator IsBusy="{Binding Busy}">
<StackPanel>
<StackPanel>
<Button/>
</StackPanel>
<Border Background="#c8c8c8" CornerRadius="5">
<sdk:DataGrid Name="myDataGrid" AutoGenerateColumns="False"
ItemsSource="{Binding Imports}" Margin="10" IsReadOnly="True">
<sdk:DataGrid.Columns>
<sdk:DataGridTextColumn Header="ID" Binding="{Binding ID}" Width=".3*"/>
<sdk:DataGridTextColumn Header="Name" Binding="{Binding Name}" Width=".7*"/>
</sdk:DataGrid.Columns>
</sdk:DataGrid>
</Border>
</StackPanel>
</c:BusyIndicator>
</ScrollViewer>
</Grid>
</navigation:Page>
What I try to accomplish is that DataGird will always have max possible width and height. It also should have min width and height fixed. When browser is smaller than DataGrid, ScrollViewer should enable srolling. I thought that Min/Max Width/Height properties will allow this behavior but i am not able to get it working.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
需要稍微改变一下标记。
StackPanel 会增长到其全部内容并防止滚动条可见。
如果在 Grid.Row 中设置一个值,网格元素会重叠内容。当您在内容上方设置繁忙指示器时,它很有用。
Need change markup a litle.
StackPanel grow to its entire content and prevent scrollbar make visible.
Grid element overlap content if you set one value in Grid.Row. It's useful when you set busyindicator above content.