【问题标题】:Oxyplot in UWP Xamarin not updatingUWP Xamarin 中的 Oxyplot 未更新
【发布时间】:2021-03-10 17:49:14
【问题描述】:

我似乎无法正确绑定到 Xamarin 中的 Oxyplot。我阅读了多个帖子,但无法弄清楚我的设置有什么问题。

XAML

<ContentPage.BindingContext>
    <local:MainViewModel />
</ContentPage.BindingContext>

<ContentPage.Content>
    
    <Grid>

        <Grid.RowDefinitions>
            <RowDefinition Height="500" />
        </Grid.RowDefinitions>

        <oxy:PlotView Grid.Row="0" Model="{Binding CandlestickPlotModel}" Background="Green"/>
        
    </Grid>
    
</ContentPage.Content>

视图模型

class MainViewModel
{
    public PlotModel CandlestickPlotModel { get; set; }

    public MainViewModel()
    {
        CandlestickPlotModel = new PlotModel();

        CandlestickPlotModel.Title = "Title";
        CandlestickPlotModel.Background = OxyColors.LightBlue;
    }
}

当我运行时,我得到一个绿色框,但如果绑定有效,我希望看到一个浅蓝色框。谁能看出这段代码有什么问题?

【问题讨论】:

  • 但是你看标题还是?
  • 不,也没有标题
  • 您是否尝试过向 PlotView 提供一些高度和宽度请求,或者您只是假设它将填充任何可用区域?
  • 我试过了,这似乎不是问题。我确实有尺寸问题,所以我什至没有得到绿色背景。我解决了这个问题,我得到了一个背景,但是 viewmodel 似乎没有正确绑定。我开始怀疑这是不是版本问题。

标签: c# xamarin uwp oxyplot


【解决方案1】:

想通了。绑定没有错。不支持 Oxyplot 1.0 和 Xamarin Forms 和 UWP。安装 Oxyplot.Xamarin.Forms 1.1.0-unstable 解决了这个问题。

【讨论】:

    猜你喜欢
    • 2017-11-24
    • 1970-01-01
    • 2018-04-06
    • 1970-01-01
    • 1970-01-01
    • 2017-12-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多