Xamarin virtual keyboard overlaps search component - xamarin.forms

In my Xamarin project I have a listview with a search box on the bottom. When I go to type in a search value the virtual keyboard overlaps the search box?
I tried to use Content.layout but I can't match the keyboard and search together Is there a way to fix this do I use a popup control?
void InputFocused(object sender, EventArgs args){
Content.LayoutTo(new Rectangle(0,-360, Content.Bounds.Width, Content.Bounds.Height));
}
void InputUnfocused(object sender, EventArgs args){
Content.LayoutTo(new Rectangle(0,0, Content.Bounds.Width, Content.Bounds.Height));
}

For ios , you can use this plugin, add to your ios project.
https://github.com/paulpatarinski/Xamarin.Forms.Plugins/tree/master/KeyboardOverlap
For android, try to add the following code in App.xaml, new App()
Xamarin.Forms.Application.Current.On<Xamarin.Forms.PlatformConfiguration.Android>().UseWindowSoftInputModeAdjust(WindowSoftInputModeAdjust.Resize);
If you still have this issue, please provide mode code here, I will try to reproduce your issue at my side.

Related

Include tabbedpage in a Xamarin forms popup

I have a popup on click of a list view.
Is it possible to include Tabbed page in the popup with two tabs?
Not sure what effect is your want.Follow is one way :
async void OnAlertYesNoClicked (object sender, EventArgs e)
{
bool answer = await DisplayAlert ("Question?", "Would you like to play a game", "Yes", "No");
Debug.WriteLine ("Answer: " + answer);
}
If you want tabs without having a TabbedPage in Xamarin.Forms, you can use those custom tabs:
https://github.com/roubachof/Sharpnado.Presentation.Forms#pure-xamarinforms-tabs-no-renderers
These are simple xamarin forms views, you can put them everywhere you like.

Dynamic Button Icon Windows app

I'm trying to do a pause/play button windows 10 app.
So far I know 3 ways to set the button using
button.context = "some segoe code" - works fine when I initialize it with the button but on the code to change the context the button appears as a bunch of squares
Button symbolicon - works fine initializing but no idea how to alter the symbolicon value outside of button declaration
button uri - only thing I could find online about button changing, but I don't have the button libraries that come in windows phone...
what is your recommendations so on clickrelease the button changes to either the pause or the play
I have used SymbolIcon to achieve the toggle play/pause.
XAML:
<Button Click="play_Click">
<SymbolIcon x:Name="play" Symbol="Play"/>
</Button>
C# code behind:
private void play_Click(object sender, RoutedEventArgs e)
{
if (play.Symbol.Equals(Symbol.Play))
{
play.Symbol = Symbol.Pause;
}
else if (play.Symbol.Equals(Symbol.Pause))
{
play.Symbol = Symbol.Play;
}
}
Comment if you encounter any issues.

How to configure ExpressionTextBox bindings / OwnerActivity when used in a dialog?

Our group is working on a Custom Activity Designer around our Email activity. It's a pretty straight forward designer, allow the user to enter settings / creds, but instead of cluttering the activity designer with all the settable options, we thought about putting some settings in a dialog window. (Which opens when you click the button beside the server address box).
Some of our email activity properties are InArguments so we are trying to make use of the ExpressionTextBox to display these values without much luck. The main problem is we aren't sure how to properly set up the binding and the OwnerActivity on the ExpressionTextBox. In the Activity Designer's xaml this is simply done by setting Expression=ModelItem.Property using a converter for the InArgument and setting the OwnerActivity=ModelItem, like this:
<view:ExpressionTextBox HintText="Enter a VB Expression" Expression="{Binding ModelItem.ServerAddress, ConverterParameter=In, Converter={StaticResource ArgumentToExpressionConverter}, Mode=TwoWay}" ExpressionType="{x:Type system:String}" OwnerActivity="{Binding ModelItem}" Margin="2" MaxLines="1" />
If anyone has any ideas on how we could accomplish this in a dialog, please advise.
Well, this is more a WPF\MVVM question than WF4, really.
When developing custom activities designers you just have to keep one thing in mind: any change made on designer\dialog should be reflected on ModelItem. Either through XAML binding expressions or through code on ModelItem.Properties property.
Now, when and how you do it, there are several answers to that but that's really an implementation detail and depends on how you want to do it.
Lets assume you're showing the dialog on button-beside-the-server-address-box click. And lets also assume you've access to dialog textboxes through their name. At that point, you've access to ModelItem so just set its properties as needed:
private void ButtonNextToServerAddressBox_OnClick(object sender, RoutedEventArgs e)
{
var dialog = new ServerAddressEditor();
var result = dialog.ShowDialog();
if (result ?? false)
{
ModelItem.Properties["Server"].SetValue(new InArgument<string>(dialog.ServerTextBox.Text));
ModelItem.Properties["Port"].SetValue(new InArgument<string>(dialog.PortTextBox.Text));
// ... set all other properties
}
}
Now, if you are using any other pattern, or you want pure MVVM, it can be a little more tricky because of how ModelItem works. But this is a totally fine approach.
I resolved this by creating a property in the dialog's ViewModel to hold the Activity Designer's ModelItem.
public ModelItem OwnerActivity {
get { return _OwnerActivity; }
set { _OwnerActivity = value; }
}
vm.OwnerActivity = this.DataContext.ModelItem;
I then set the Xaml for the Expression Text Box in my dialog to binding to this:
<view:ExpressionTextBox HintText="Enter a VB Expression" Expression="
{Binding Path=OwnerActivity.ServerAddress, ConverterParameter=In, Converter=
{StaticResource ArgumentToExpressionConverter}, Mode=TwoWay}" ExpressionType="
{x:Type system:String}" OwnerActivity="{Binding OwnerActivity}" Margin="2"
MaxLines="1" />
Because I'm now binding directly to the ModelItem from the Activity Designer, any change made to the ModelItem property from the dialog is ALWAYS committed, even if you choose to Cancel from the dialog. To wire up the Ok/Cancel buttons so they work accordingly, I did the following in the dialog:
// declare a ModelEditingScope to make changes transactional
private ModelEditingScope _editScope;
// add this to the constructor of the dialog to begin transactional edits on the ModelItem
_editScope = editorViewModel.OwnerActivity.BeginEdit();
// ok & cancel button click event to commit or revert the changes.
private void OK_Click(object sender, RoutedEventArgs e)
{
_editScope.Complete();
this.DialogResult = DialogResult.OK;
this.Close();
}
private void Cancel_Click(object sender, RoutedEventArgs e)
{
_editScope.Revert();
this.DialogResult = DialogResult.Cancel;
this.Close()
}

WPF equivalent of RootVisual in Caliburn.Micro docs

I am trying to work through the Caliburn.Micro Soup to Nuts tutorials using WPF rather than Silverlight.
In the "All About Actions" section of the Caliburn.Micro tutorial the following Silverlight code is shown in the overridden MefBootstrapper:
public class MefBootstrapper : BootstrapperBase
{
//same as before
protected override void OnStartup(object sender, StartupEventArgs e)
{
Application.RootVisual = new ShellView();
}
//same as before
}
With the comment "In this scenario, we simply override OnStartup, instantiate the view ourselves and set it as the RootVisual (or call Show in the case of WPF)."
Does anyone know what is the format of the Show command that is used? (I have tried a number of internet researched items but none worked). I'm guessing it must be very simple because of the casual mention in the tutorial...

NavigateToViewModel with Caliburn Micro 2 and Windows Phone 8.1

I'm trying to figure out how to successfully get Caliburn Micro to navigate from one page to another in a Windows Phone 8.1 app.
My first page loads just fine, as specified in my App class:
protected override void OnLaunched(LaunchActivatedEventArgs args)
{
this.DisplayRootViewFor<HomeViewModel>();
}
This launches the HomeView without issue. On that view I have a button that calls the following method:
public void GoToPage2()
{
this.navigationService.NavigateToViewModel<Page2ViewModel>();
}
This method is called when the button is pressed and the constructor for Page2ViewModel is called as well. The page just never displays and I can't figure out why. I feel like I'm missing a core concept, but I can't find any examples of how this should work.
Thanks for any help.
The solution is odd, and perhaps a bug in Caliburn Micro. In the OnLaunched method I used to have:
protected override void OnLaunched(LaunchActivatedEventArgs args)
{
this.DisplayRootViewFor<HomeViewModel>();
}
This worked and launched the home view, but subsequent navigation never worked. After comparing to a sample application I found, I changed the code to:
protected override void OnLaunched(LaunchActivatedEventArgs args)
{
this.DisplayRootView<HomeView>();
}
This also displays the home view, but now subsequent navigation works! I'm not sure why this would be the case, but at least I have an answer.

Resources