0

我有以下 xaml 文件

<Window x:Class="NodeXL_Graph_Drawer.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:toolkit="http://schemas.microsoft.com/wpf/2008/toolkit"
    xmlns:controls="clr-namespace:Technewlogic.Samples.WpfModalDialog"                      
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" DataContext="{Binding RelativeSource={RelativeSource Self}}"
Title="NodeXL Graph" xmlns:my="clr-namespace:Smrf.NodeXL.Visualization.Wpf;assembly=Smrf.NodeXL.Control.Wpf" Loaded="Window_Loaded">
<Grid>
    <Grid x:Name="ModalDialogParent" >
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*" x:Name="col1"/>
            <ColumnDefinition Width="5" />
            <ColumnDefinition Width="*"/>
        </Grid.ColumnDefinitions>
        <StackPanel Grid.Column="0" >
            <my:NodeXLControl Name="nodeXLControl1" HorizontalAlignment="Left"  EdgeSelectedColor="Red" VertexSelectedColor="Red" ShowVertexToolTips="True" VertexClick="nodeXLControl1_VertexClick" SelectionChanged="nodeXLControl1_SelectionChanged" MouseMode="Select" MouseAlsoSelectsIncidentEdges="False" ContextMenuOpening="nodeXLControl1_ContextMenuOpening" GraphLaidOut="nodeXLControl1_GraphLaidOut">

            </my:NodeXLControl>
        </StackPanel>
        <!--<ComboBox Height="23" Margin="39,12,119,0" Name="comboBox1" VerticalAlignment="Top" SelectionChanged="comboBox1_SelectionChanged" />-->
        <GridSplitter Grid.Column="1" HorizontalAlignment="Stretch"/>

        <StackPanel Grid.Column="2">                
            <toolkit:DataGrid AutoGenerateColumns="True" Margin="0,62,0,0" Name="grdGraphDetails" ItemsSource="{Binding GraphDetail}" IsReadOnly="True" 
                          HorizontalAlignment="Right" Width="109" MouseLeftButtonUp="grdGraphDetails_MouseLeftButtonUp" 
                          SelectedValuePath="Key" Height="179" />              
        </StackPanel>

    </Grid>
    <controls:ModalDialog x:Name="ModalDialog"></controls:ModalDialog>         
    <controls:ModalDialog1 x:Name="ModalDialog1"></controls:ModalDialog1>
</Grid>    

在这里,我在由网格分隔符分隔的页面上有两个控件 NodeXlControl1 和 Datagrid1。当窗口加载时 NodeXlControl1 不在网格列的宽度和高度范围内。我希望 nodexlcontrol1 应该显示在网格列的宽度和高度中。我如果超出列的宽度和高度的限制,滚动条应该来。

4

1 回答 1

0

如果您的my:NodeXLControl内部有一些滚动查看器(例如 someItemsControlScrollViewerbased child),那么简单地包装my:NodeXLControlaGrid就可以了。

StackPanel扩展以溢出孩子。Grid扩展到外部容器的可用空间。

<Grid>
    <my:NodeXLControl  ... />

应该做的伎俩。

但是,如果您my:NodeXLControl没有滚动查看器,那么您需要将其包装在其中并为其提供absolute宽度或高度,或者将其包装在 aGrid中以使其绑定到其可用空间并相应地显示滚动条。

例如

   <Grid>
      <ScrollViewer ...>
        <my:NodeXLControl ...>
于 2012-10-23T12:14:37.037 回答