【问题标题】:wp 8.1 usercontrol and OxyPlot not showing upwp 8.1 用户控件和 OxyPlot 未显示
【发布时间】:2015-09-25 03:13:24
【问题描述】:

我有一个带有网格作为内容面板的用户控件,它从数据模板加载其内容,在 xaml 中指定使用用户控件的位置。

我正在广泛使用此用户控件,并且模板中的标准 xaml 控件一切正常。 现在我正在尝试使用 OxyPlot 在此控件中显示一些图表

   <DataTemplate x:Key="SomeChart">
        <Grid x:Name="oxyGrid" >
            <oxy:PlotView x:Name="oxyChart" Model="{Binding model}" />
        </Grid>
    </DataTemplate>

我在 usercontrol_loaded 中初始化图表的数据模型 但在我手动调用 InvalidateMeasure 之前,图表不会显示。 如果我从 usercontrol_loaded 调用 invalidatemeasure ,它将无济于事。

如果我在屏幕上显示图表时从任何时候调用 invalidatemeasure - 它会有所帮助,并且图表会显示出来。

目前,我发现我可以在 usercontrol_layoutupdated 处理程序中调用 invalidatemeasure 但不喜欢它,因为它经常触发 并且需要用户控制之外的代码。

如果我尝试在用户控件中处理事件 layoutupdated 并从那里调用 invalidatemeasure(用于 oxychart),我会收到“检测到布局周期。布局无法完成​​。”

关于哪里出了问题以及如何解决的任何想法 :) 将不胜感激 提前致谢 伊莉亚

【问题讨论】:

    标签: c# user-controls windows-phone-8.1 oxyplot


    【解决方案1】:

    从不急于发布问题:)

    加载模板后只需在用户控件中调用UpdateLayout()

       private void spContentPanel_Loaded(object sender, RoutedEventArgs e)
        {
            LoadTemplate();
            UpdateLayout();
        }
    

    其中 spContentPanel 只是用于模板加载的网格

       <Grid Grid.Row="1" Name="spContentPanel" Loaded="spContentPanel_Loaded"
              HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
    
        </Grid>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-04-06
      • 1970-01-01
      • 2014-10-12
      • 2012-12-03
      • 1970-01-01
      • 2018-11-20
      相关资源
      最近更新 更多