如何调整Winform应用程序调整大小时Winform中使用的WPF用户控件的大小

时间:2014-08-29 07:59:40

标签: c# .net wpf xaml telerik

我是wpf的新手,并在system.windows.forms.tabpage内的winform应用程序中使用wpf用户控件。

wpf控制代码

  <UserControl x:Class="VMS_TimelineControl.WpfTimeline"
         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
         xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
         xmlns:local="clr-namespace:VMS_TimelineControl"
         xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
         mc:Ignorable="d" Height="161" Width="1135" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Name="usercontrol">

   <Grid Name="grid" Margin="0,0,10.085,0.489" Height="153" Width="1125">

      <Grid.Resources>

      </Grid.Resources>

      <telerik:RadTimeline x:Name="Timeline" Height="153" Width="1125"
      </telerik:RadTimeline>

   </Grid>

 </UserControl>

使用此控件的Winform代码

        timeLine = new WpfTimeline();
        TimeLineData data = new TimeLineData();
        data.startdate = StartTime;
        data.enddate = EndTime;
        data.DataToPlot = events;          
        timeLine.DataContext = data;

        timeLine.SendEventDateTime += TimeLinePlayVideo;
        //Elementhost ----> host for timeline control in winforms
        this.timelineHost.Height = ((int)timeLine.Height) + 10;
        this.timelineHost.Width = (int)timeLine.Width;
        this.timelineHost.Child = timeLine;
        this.timelineHost.BringToFront();            
        tabPage1.Controls.Add(this.timelineHost);
        //tabPage1  is the tab inside whos tabpage this wpf control is hosted.

现在我想在winform应用程序时调整wpf控件的大小。窗口调整大小。 tabpage调整大小但wpf控件没有。 我该怎么做。??

窗口全尺寸时的

tabpage屏幕截图

enter image description here

窗口调整大小时

enter image description here

请帮忙。

0 个答案:

没有答案
相关问题