0

如何在 RadPane 的 TitleTemplate 中获取 GridSplitter 的句柄

<telerik:RadPane TitleTemplate="{StaticResource radPaneHeaderFormat}" ContextMenuTemplate="{x:Null}" CanDockInDocumentHost="False"  x:Name="radPane" Header="HeaderTitle" CanUserClose="False" CanFloat="False"    VerticalAlignment="Center" />

    <DataTemplate x:Key="radPaneHeaderFormat}"  ">
        <Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch" >
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="670" MaxWidth="678"/>
           <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="0.1*" />
            </Grid.ColumnDefinitions>

            <Button x:Name="ViewButton" Margin="0,0,5,0" Style="{StaticResource LeftArrowButtonStyle}" Click="ViewButton_Click" />
            <TextBlock Text="Summary" VerticalAlignment="Center" Grid.Column="1" />
            <sdk:GridSplitter Height="Auto"  Grid.Column="2" Name="HeaderSplitter" VerticalAlignment="Stretch" Style="{StaticResource newGridSplitterStyle}" />                               
             <TextBlock Text="Note"  Grid.Column="3" VerticalAlignment="Center"  Margin="3,0,0,0"/>
        </Grid>
    </DataTemplate>

任何人都可以帮我解决这个问题。

4

1 回答 1

0

我不知道您想从哪里访问GridSplitter,但是,鉴于您有一个ButtonwithClick事件处理程序,我将向您展示如何在其中访问它:

    private void ViewButton_Click(object sender, RoutedEventArgs e)
    {
        var button = sender as Button;
        var panel = button.Parent as Panel;
        if (panel != null)
        {
            GridSplitter splitter = panel.Children.OfType<GridSplitter>().First();
            // do stuff with the GridSplitter...
        }
    }

using System.Linq;如果您还没有一行,则需要添加一行。

在这种情况下,我利用了按钮的Click事件处理程序将被单击的按钮传递给我们的事实,并且 theButtonGridSplitter具有相同的父级。

于 2012-08-09T14:40:19.147 回答