I have Main Navigation Page JobInfoPage with ListView contains all jobs information. When i click a button/Image it shows selected job information i.e Notes and job name. When i edit and Save on JobNotesPage it is updating Job filed in data but not on a ListView.
I set Binding to JobNotes in Xaml and TwoBinding Still not working.
Could any one suggest what i am doing wrong.
Source Code can be downloaded from
https://spaces.hightail.com/receive/g8rg2VWW6o[
^]
What I have tried:
I set Binding to JobNotes in Xaml and TwoBinding Still not working.
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:UpdateNotes"
x:Class="UpdateNotes.JobInfoPage">
<ContentPage.BindingContext>
<local:JobInfoViewModel/>
</ContentPage.BindingContext>
<ContentPage.Resources>
<ResourceDictionary>
<local:NotesConverter x:Key="NotesConverter"/>
<local:RemarksConverter x:Key="RemarksConverter"/>
</ResourceDictionary>
</ContentPage.Resources>
<ContentPage.Content>
<StackLayout HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand">
<ListView x:Name="JobsList" ItemsSource="{Binding JobsInfo, Mode=TwoWay}" HasUnevenRows="True" Margin="0" >
<ListView.ItemTemplate>
<DataTemplate >
<ViewCell >
<StackLayout HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" Padding="5,0,5,0" Margin="0" >
<StackLayout Orientation="Horizontal" HorizontalOptions="FillAndExpand" Padding="0,0,0,0" Margin="0,0,0,-3">
<Label Text="{Binding JobNumber}" />
<Label Text="05-07-2017" HorizontalOptions="EndAndExpand" />
</StackLayout>
<Label Text="{Binding JobName}" FontAttributes="Bold" Margin="0,-3,0,-3" TextColor="Black" VerticalOptions="StartAndExpand" />
<Label Text="{Binding JobNotes, Mode=TwoWay}" TextColor="Black" Margin="0,-3,0,-3" HorizontalOptions="FillAndExpand" VerticalOptions="StartAndExpand" FontSize="Micro" IsVisible="{Binding Converter={StaticResource NotesConverter}}" FontAttributes="Italic" BackgroundColor="LightYellow" />
<Label Text="{Binding JobRemarks, Mode=TwoWay}" TextColor="Black" Margin="0,-3,0,2" HorizontalOptions="FillAndExpand" VerticalOptions="StartAndExpand" FontSize="Micro" IsVisible="{Binding Converter={StaticResource RemarksConverter}}" FontAttributes="Italic" BackgroundColor="LightPink" />
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
<StackLayout Orientation="Horizontal" Margin="1" HorizontalOptions="StartAndExpand" VerticalOptions="Center">
<Image x:Name = "ViewJobText" Margin="10" Source="JobText.png" VerticalOptions="Center" HorizontalOptions="StartAndExpand">
<Image.GestureRecognizers>
<TapGestureRecognizer Tapped="OnViewJobTextGestureTap" NumberOfTapsRequired="1" />
</Image.GestureRecognizers>
</Image>
<Image x:Name = "ViewNotes" Margin="10" Source="Notes.png" VerticalOptions="Center" HorizontalOptions="StartAndExpand">
<Image.GestureRecognizers>
<TapGestureRecognizer Tapped="OnViewNotesGestureTap" NumberOfTapsRequired="1" />
</Image.GestureRecognizers>
</Image>
<Image x:Name = "ViewRemarks" Margin="10" Source="Remarks.png" VerticalOptions="Center" HorizontalOptions="StartAndExpand">
<Image.GestureRecognizers>
<TapGestureRecognizer Tapped="OnViewRemarksGestureTap" NumberOfTapsRequired="1" />
</Image.GestureRecognizers>
</Image>
<!--<Button Text="View Text" HeightRequest="20"/>
<Button x:Name = "ViewNotes" HeightRequest="20" BackgroundColor="LightYellow" BorderWidth="0" Margin="0" Image="Notes.png" TextColor="Black" Clicked="ViewNotes_Clicked"/>
<Button Text="View Remarks" HeightRequest="20" BackgroundColor="LightPink" TextColor="Black"/>-->
</StackLayout>
</StackLayout>
</ContentPage.Content>
</ContentPage>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Reflection;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
namespace UpdateNotes
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class JobNotesPage : ContentPage
{
Stream fileStream;
String pdfFileName;
public JobNotesPage (JobInfo Injob)
{
//Syncfusion.Licensing.SyncfusionLicenseProvider.RegisterLicense("NTk1M0AzMTM2MmUzMjJlMzBEbXMzR0ZieGtzZFQwOFRTSnBvR3kvbjFCYW43d3VvOE9EcU9ocjRWRUlFPQ==");
this.InitializeComponent();
BindingContext = Injob;
if (Injob != null)
{
pdfFileName = Injob.SectionCode + Injob.JobCode + ".PDF";
}
}
protected override void OnAppearing()
{
base.OnAppearing();
if (App.DataPath is null)
{
App.DataPath = DependencyService.Get<igetdatapath>().GetDataPath();
}
//fileStream = typeof(App).GetTypeInfo().Assembly.GetManifestResourceStream("UpdateNotes.Assets.D5.pdf");
//pdfViewerControl.MaximumZoomPercentage = 300;
if (!String.IsNullOrEmpty(pdfFileName))
{
var filename = Path.Combine(App.DataPath, pdfFileName);
if (File.Exists(filename))
{
fileStream = new FileStream(filename, FileMode.Open);
}
}
}
protected override void OnDisappearing()
{
base.OnDisappearing();
fileStream.Close();
}
void OnInsertImageGestureTap(object sender, EventArgs e)
{
// handle the tap
DisplayAlert("Alert", "This is an image button", "OK");
}
private async void NavigateButton_OnClicked(object sender, EventArgs e)
{
await Navigation.PushAsync(new JobInfoPage());
}
private async void OnSavNotesGestureTap(object sender, EventArgs e)
{
JobInfo Injob = BindingContext as JobInfo;
Injob.JobNotes = txtJobNotes.Text;
await Navigation.PushModalAsync(new JobInfoPage());
}
}
}