Xamarin标签绑定上下文

时间:2018-01-09 14:03:20

标签: c# xaml xamarin xamarin.forms

我的绑定上下文似乎存在问题

我已经将bindingcontext更改为this,我已经尝试过对该值进行硬编码,但这也没有用。我已经检查了Issue.Createdby的值,并且它填充了用户名,但是没有显示。这是我遇到问题的唯一绑定。

页面的构造函数

session.run(other_op, feed_dict={feature_map: <new value>})

页面出现,其中Issue.CreatedBy已填满但未在屏幕上显示。如果你愿意,我可以添加GetcurrentUserName方法,但由于它被正确填充似乎无关紧要。

public EditIssuePage(UIIssueVM issue, IssueCarouselPage parentPage)
                {
                    InitializeComponent();
                    _parentPage = parentPage;
                    Issue = issue;
                    StatusValues = Issue.PossibleStatusValues;
                    SeverityValues = Issue.PossibleSeverityValues;
                    Items = new ObservableCollection<UIImageVM>();
                    BindingContext = issue;

                }   

代码的XAML部分

        protected async override void OnAppearing()

                    if (Issue.IsNew)
                    {
                        Title = "New Event";
                        severity3.Opacity = 1;
                        Issue.Severity = IssueSeverity.Medium;
                        Issue.Status = IssueStatus.Done;
                        Issue.CreatedBy = App.Client.GetCurrentUsername();
                    }

问题代码如何与

绑定
     <!--Date Created-->
                    <Frame OutlineColor="#FBB040">
                        <StackLayout Grid.Column="0" Grid.Row="1" Orientation="Horizontal" VerticalOptions="Center" HorizontalOptions="FillAndExpand" Spacing="6" BackgroundColor="Black">
                            <Label Text="TIME AND DATE: " Style="{StaticResource Labelfont}"/>
                            <Label Text="{Binding Created, Converter={StaticResource DateToTextConverter}}"  Style="{StaticResource Labelfont}"/>
                        </StackLayout>
                    </Frame>

                    <!--REPORTED BY-->
                    <Frame OutlineColor="#FBB040">
                        <StackLayout  Grid.Column="0" Grid.Row="2" Orientation="Horizontal" VerticalOptions="Center" HorizontalOptions="FillAndExpand" Spacing="6" BackgroundColor="Black">
                            <Label Text="REPORTED BY: " Style="{StaticResource Labelfont}"/>
                            <Label x:Name="createdBy" Text="{Binding CreatedBy}"  Style="{StaticResource Labelfont}" />
                        </StackLayout>
                    </Frame>

0 个答案:

没有答案