protected override void OnAppearing()
{
base.OnAppearing();
Device.BeginInvokeOnMainThread( () =>
{
WaitingIndicator.IsRunning = true;
var dataModel = new ClassListViewModel();
ListViewClass.ItemsSource = dataModel.Classes;
ListViewClass.IsPullToRefreshEnabled = true;
ListViewClass.RefreshCommand = dataModel.RefreshCommand;
ListViewClass.BackgroundColor = Color.FromHex("#BDBAB6");
ListViewClass.RowHeight = 200;
ListViewClass.SeparatorVisibility = SeparatorVisibility.None;
ListViewClass.ItemTemplate = new DataTemplate(Function);
ListViewPagningBehavior ListViewBehaviour = new ListViewPagningBehavior();
ListViewBehaviour.Converter = new ItemVisibilityEventArgstemConverter();
ListViewBehaviour.Command = dataModel.LoadMoreCommand;
ListViewClass.Behaviors.Add(ListViewBehaviour);
//BindingContext = dataModel;
ListViewClass.SetBinding(ListView.IsRefreshingProperty, "IsBusy");
ListViewClass.BindingContext = dataModel;
stack.Children.Remove(WaitingIndicator);
});
i am flipping to the above page from another page
my problem is that the page is not showing until the bindingcontext is finishing
but i want to show the waiting indicator to the user while waiting binding
Related
Hi I have upgrade my application from 45 to Cefsharp version 71,Earlier new created tab is easily dispose(remove) but now the whole application is shut down,When i am using remove method the tab is closed but it remain in the memory that cause system hanged.
public void AddNewBrowserTab(string url, int? insertIndex = null) {
browserTabControl.SuspendLayout();
var browser = new BrowserTabUserControl(AddNewBrowserTab, url, UserName, pass, browserTabControl, txtUName.Text.ToString().Trim(), txtUPassword.Text.ToString().Trim(), MUser, TUser);
var tabPage = new TabPage(url);
browser.CreateControl();
tabPage.Controls.Add(browser);
if (insertIndex == null) {
browserTabControl.TabPages.Add(tabPage);
} else {
browserTabControl.TabPages.Insert(insertIndex.Value, tabPage);
}
browserTabControl.SelectedTab = tabPage;
browserTabControl.ResumeLayout(true);
}
//Call Method
public BrowserTabUserControl(Action<string, int?> openNewTab, string url, string uname, string pwd, TabControl browserTabControl, string loginUsrname, string LoginUsrpwd, string muser, string thuser) {
InitializeComponent();
MonsterUsr = monsteruser;
Techfetchuser = techfetchuser;
loginUsername = loginUsrname;
name = uname;
passwd = pwd;
txtuname = loginUsrname;
txtupwd = LoginUsrpwd;
browserTabControls = browserTabControl;
var browser = new ChromiumWebBrowser(url) {
Dock = DockStyle.Fill
};
var userControl = new UserControl { Dock = DockStyle.Fill };
ZoomIn.Controls.Add(browser);
Browser = browser;
browser.MenuHandler = new MenuHandler();
browser.JsDialogHandler = new JsDialogHandler();
browser.AddressChanged += Browser_AddressChanged;
browser.DownloadHandler = new DownloadHandler(browserTabControl);
browser.LifeSpanHandler = new LifeSpanHandler(browserTabControl, ref Browser, loginUsrname, LoginUsrpwd);
browser.KeyboardHandler = new KeyboardHandler();
}
I'm using the Devexpress MVC Grid and I've added two custom buttons (Edit & Copy) and I'm performing the operations. With copy button, I'm creating a new record with existing data and opening the grid in Add New Row Mode.
Following is the code:
#Html.DevExpress().GridView(grid =>
{
grid.Name = "gvInformation";
grid.SettingsDetail.AllowOnlyOneMasterRowExpanded = true;
grid.SettingsEditing.Mode = GridViewEditingMode.EditForm;
//Callback Events
grid.CallbackRouteValues = new { Controller = "Case", Action = "InformationGridContent"};
grid.SettingsEditing.AddNewRowRouteValues = new { Controller = "Case", Action = "AddInformationRecord" };
grid.SettingsEditing.UpdateRowRouteValues = new { Controller = "Case", Action = "UpdateInformationRecord" };
grid.SettingsEditing.DeleteRowRouteValues = new { Controller = "Case", Action = "DeleteInformationRecord" };
grid.ClientSideEvents.BeginCallback = "BeginGridCallback";
grid.BeforeGetCallbackResult = (sender, e) =>
{
MVCxGridView gridView = sender as MVCxGridView;
if (isCopyRequired)
gridView.AddNewRow();
if (gridView.IsNewRowEditing)
{
gridView.SettingsText.CommandUpdate = Html.Raw("<span id='btnGridAdd'>Add</span>").ToHtmlString();
gridView.SettingsText.CommandCancel = Html.Raw("<span id='btnGridCancel'>Cancel</span>").ToHtmlString();
}
if (!gridView.IsNewRowEditing)
{
gridView.SettingsText.CommandUpdate = Html.Raw("<span id='btnGridUpdate'>Update</span>").ToHtmlString();
gridView.SettingsText.CommandCancel = Html.Raw("<span id='btnCancel'>Cancel</span>").ToHtmlString();
}
};
//Custom Copy Record Button
var btnCopy = new GridViewCommandColumnCustomButton { ID = "btnCopy" };
btnCopy.Text = "<i class=\"fa fa-copy fa-lg\" title='Copy'></i>";
grid.CommandColumn.CustomButtons.Add(btnCopy);
//Custom Edit Button
var btnEdit = new GridViewCommandColumnCustomButton { ID = "btnEdit" };
btnEdit.Text = "<i class=\"fa fa-pencil fa-lg\" title='Edit'></i>";
grid.CommandColumn.CustomButtons.Add(btnEdit);
//Custom Button Events
grid.ClientSideEvents.CustomButtonClick = "OnCustomButtonClick";
grid.CustomActionRouteValues = new { Controller = "Case", Action = "CustomInformationRecord" };
}
Client Side Events:
var buttonCommand;
function OnCustomButtonClick(s, e) {
buttonCommand = e.buttonID;
s.PerformCallback();
}
function BeginGridCallback(s, e) {
//Grid Edit Button Click Event
if (buttonCommand === "btnEdit") {
e.customArgs["buttonCommand"] = "btnEdit";
}
//Grid Copy Button Click Event
if (buttonCommand === "btnCopy") {
e.customArgs["buttonCommand"] = "btnCopy";
}
}
It is working fine for Copy button and opening the Grid in Edit Form Mode but when Edit Button is clicked it is not opening the Grid in Edit Mode. Is there something I'm missing?
I use the Iconize plugin for my project, and there is an issue that occurs in case of the IconToolbarItem is used in a IconNavigationPage, that is itself used in the Detail of a MasterDetailPage.
If we launch the UWP project from IconizeSample, the IconToolbarItems are well displayed in the TabbedPage:
var tabbedPage = new IconTabbedPage { Title = "Iconize" };
foreach (var module in Plugin.Iconize.Iconize.Modules)
{
tabbedPage.Children.Add(new Page1
{
BindingContext = new ModuleWrapper(module),
Icon = module.Keys.FirstOrDefault()
});
}
MainPage = new IconNavigationPage(tabbedPage);
If we replace the TabbedPage by a MasterDetailPage, this also works if the Detail is not a IconNavigationPage:
var mdPage = new MasterDetailPage();
mdPage.Master = new ContentPage
{
Title = "Iconize"
};
var module = Plugin.Iconize.Iconize.Modules.First();
mdPage.Detail = new Page1
{
BindingContext = new ModuleWrapper(module),
Icon = module.Keys.FirstOrDefault()
};
MainPage = new IconNavigationPage(mdPage);
But if we put the Detail in an IconNavigationPage, the icons of the IconToolbarItem are no longer visible:
var mdPage = new MasterDetailPage();
mdPage.Master = new ContentPage
{
Title = "Iconize"
};
var module = Plugin.Iconize.Iconize.Modules.First();
mdPage.Detail = new IconNavigationPage(new Page1
{
BindingContext = new ModuleWrapper(module),
Icon = module.Keys.FirstOrDefault()
});
MainPage = mdPage;
Would you have an explanation? Is there a way to fix this awaiting a new package version?
But if we put the Detail in an IconNavigationPage, the icons of the IconToolbarItem are no longer visible:
The problem is that you have not inserted the mdPage into IconNavigationPage. I have modified your code and it works.
var mdPage = new MasterDetailPage();
mdPage.Master = new ContentPage
{
Title = "Iconize"
};
var module = Plugin.Iconize.Iconize.Modules.First();
var page = new Page1
{
BindingContext = new ModuleWrapper(module),
Icon = module.Keys.FirstOrDefault()
};
mdPage.Detail = page;
MainPage = new IconNavigationPage(mdPage);
I have a RecyclerView that contains cardViews as members and cardviews contains image views that there images come from urls with an async method.
It works but when i scroll it fast several times it causes to an unhandled error.
what shoud I do?
public override async void OnBindViewHolder(RecyclerView.ViewHolder viewHolder, int position)
{
var item = items[position];
var holder = viewHolder as MyViewHolder;
holder.image.SetImageBitmap(null);
holder.fname.Text = items[position].fname;
holder.sname.Text = items[position].sname;
holder.age.Text = items[position].age.ToString();
holder.progressLayout.Visibility = ViewStates.Visible;
using (var imageBitmap = await GetImageBitmapFromUrl(items[position].imageURL))
{
var width = imageBitmap.Width;
var height = imageBitmap.Height;
var max = Math.Max(width, height);
var scale = (double)holder.image.Width / max;
var scaled = Bitmap.CreateScaledBitmap(imageBitmap, (int)(width * scale), (int)(height * scale), false);
holder.image.SetImageBitmap(scaled);
}
holder.progressLayout.Visibility = ViewStates.Gone;
}
private async Task<Bitmap> GetImageBitmapFromUrl(string url)
{
Bitmap imageBitmap = null;
using (var webClient = new WebClient())
{
var imageBytes = await webClient.DownloadDataTaskAsync(url);
if (imageBytes != null && imageBytes.Length > 0)
{
imageBitmap = await BitmapFactory.DecodeByteArrayAsync(imageBytes, 0, imageBytes.Length);
}
}
return imageBitmap;
}
Solved,
I disposed the "scaled" variable after setting it as imageview bitmap
var scaled = Bitmap.CreateScaledBitmap(imageBitmap, (int)(width * scale), (int)(height * scale), false);
holder.image.SetImageBitmap(scaled);
scaled.Dispose(); // here
In my application, I am generating a datagrid programatically and binding it with a list. I am able to see the data in the datagrid but when I edit the cell, the underlying item in the list does not get updated. Here is the code
Window dateChangeWindow = new Window();
dateChangeWindow.WindowStartupLocation = WindowStartupLocation.CenterOwner;
dateChangeWindow.Owner = Application.Current.MainWindow;
dateChangeWindow.SizeToContent = SizeToContent.WidthAndHeight;
dateChangeWindow.Title = "Date Change";
StackPanel stackPanel = new StackPanel();
stackPanel.Orientation = Orientation.Vertical;
DataGrid requestGrid = new DataGrid();
requestGrid.CanUserResizeColumns = false;
requestGrid.CanUserResizeRows = false;
requestGrid.CanUserReorderColumns = false;
requestGrid.CanUserSortColumns = true;
requestGrid.AutoGenerateColumns = false;
DataGridTextColumn requestIdColumn = new DataGridTextColumn();
requestIdColumn.Header = "Request Id";
Binding idBinding = new Binding("RequestId");
idBinding.Mode = BindingMode.OneWay;
requestIdColumn.Binding = idBinding;
requestGrid.Columns.Add(requestIdColumn);
DataGridTemplateColumn startDateColumn = new DataGridTemplateColumn();
startDateColumn.Header = "Start Date";
Binding startDateBinding = new Binding("StartDate");
startDateBinding.Mode = BindingMode.TwoWay;
FrameworkElementFactory startDateFactory = new FrameworkElementFactory(typeof(DatePicker));
startDateFactory.SetBinding(DatePicker.SelectedDateProperty, startDateBinding);
DataTemplate startDateTemplate = new DataTemplate();
startDateTemplate.VisualTree = startDateFactory;
startDateColumn.CellTemplate = startDateTemplate;
startDateColumn.CellEditingTemplate = startDateTemplate;
requestGrid.Columns.Add(startDateColumn);
DataGridTemplateColumn endDateColumn = new DataGridTemplateColumn();
endDateColumn.Header = "End Date";
Binding endDateBinding = new Binding("EndDate");
endDateBinding.Mode = BindingMode.TwoWay;
FrameworkElementFactory endDateFactory = new FrameworkElementFactory(typeof(DatePicker));
endDateFactory.SetBinding(DatePicker.SelectedDateProperty, endDateBinding);
DataTemplate endDateTemplate = new DataTemplate();
endDateTemplate.VisualTree = endDateFactory;
endDateColumn.CellTemplate = endDateTemplate;
endDateColumn.CellEditingTemplate = endDateTemplate;
requestGrid.Columns.Add(endDateColumn);
requestGrid.ItemsSource = requestList;
requestGrid.Margin = new Thickness(0, 10, 0, 0);
requestGrid.HorizontalAlignment = HorizontalAlignment.Center;
stackPanel.Children.Add(requestGrid);
Button changeDoneBtn = new Button();
changeDoneBtn.Content = "Submit";
changeDoneBtn.Click += new RoutedEventHandler(changeDone_Click);
changeDoneBtn.Margin = new Thickness(0, 20, 0, 10);
changeDoneBtn.HorizontalAlignment = HorizontalAlignment.Center;
stackPanel.Children.Add(changeDoneBtn);
dateChangeWindow.Content = stackPanel;
dateChangeWindow.ShowDialog();
The ItemsSource requestList is populated before the window creation. It is declared as
IList<DateChangeWrapper> requestList = new List<DateChangeWrapper>();
And the DateChangeWrapper class looks like this
public class DateChangeWrapper : INotifyPropertyChanged
{
public DateChangeWrapper(ResponseWrapper responseWrapper)
{
RequestId = responseWrapper.RequestId;
ParentRequestId = responseWrapper.ParentRequestId;
StartDate = responseWrapper.StartDate;
EndDate = responseWrapper.EndDate;
}
private DateTime startDate;
private DateTime endDate;
public int RequestId { get; private set; }
public int ParentRequestId { get; private set; }
public DateTime StartDate
{
get { return startDate; }
set
{
startDate = value;
OnPropertyChanged("StartDate");
}
}
public DateTime EndDate
{
get { return endDate; }
set
{
endDate = value;
OnPropertyChanged("EndDate");
}
}
public event PropertyChangedEventHandler PropertyChanged;
private void OnPropertyChanged(string propertyName)
{
PropertyChangedEventHandler handler = PropertyChanged;
if (handler != null)
{
var e = new PropertyChangedEventArgs(propertyName);
handler(this, e);
}
}
}
As you can see from the code, I have two columns StartDate and EndDate which are displayed as DatePickers . When I debug the code, the point where window.ShowDialog is called, I see the get accessor of the Dates getting called. But when I change the value in the datepicker, the setter does not get called and my list still has the old value.
Please help me
The problem was that the changed value was not getting updated back to the underlying source because of UpdateSourceTrigger. By default, this has the value of LostFocus. I changed it to PropertyChanged and it worked ! :)
I added the following line of code to my binding
startDateBinding.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;
and similarly for EndDate