Custom ContextAction with Xamarin Forms

I using a Xamarin Forms ListView and I want to enable or disable the Context Actions based on a certain binding or in the code behind.

The way I found is to use BindingContextChanged in a ViewCell. I show you an example

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml">
  <ContentPage.Content>
    <StackLayout>
      <ListView x:Name="listDictionaries" 
                ItemsSource="{Binding DictionariesList}" 
                IsVisible="{Binding ShowList}"
                HorizontalOptions="FillAndExpand" 
                VerticalOptions="FillAndExpand" 
                HasUnevenRows="true" 
                IsPullToRefreshEnabled="true" 
                RefreshCommand="{Binding Refresh}" 
                SeparatorVisibility="Default" 
                ItemTapped="OnItemTapped" 
                IsRefreshing="{Binding IsBusy, Mode=OneWay}">
        <ListView.ItemTemplate>
          <DataTemplate>
            <ViewCell BindingContextChanged="OnBindingContextChanged">
              <ViewCell.View>
                <StackLayout>
                  <Grid Padding="10" ColumnSpacing="10">
                    <Grid.RowDefinitions>
                      <RowDefinition Height="*" />
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                      <ColumnDefinition Width="Auto" />
                      <ColumnDefinition Width="*" />
                    </Grid.ColumnDefinitions>
                    <Label Text="{Binding Name}" FontSize="Large" 
                           Grid.Row="0" Grid.Column="0" />
                    <Label Text="{Binding Description}" FontSize="Small" 
                           Grid.Row="1" Grid.Column="0" />
                  </Grid>
                </StackLayout>
              </ViewCell.View>
            </ViewCell>
          </DataTemplate>
        </ListView.ItemTemplate>
      </ListView>
    </StackLayout>
  </ContentPage.Content>
</ContentPage>

Then you insert in the code the following code:

/// <summary>
/// Called when binding context changed.
/// </summary>
/// <param name="sender">The sender.</param>
/// <param name="e">The <see cref="EventArgs"/> 
/// instance containing the event data.</param>
private void OnBindingContextChanged(object sender, EventArgs e) {
    base.OnBindingContextChanged();

    if (BindingContext == null)
        return;

    ViewCell theViewCell = ((ViewCell)sender);
    var item = theViewCell.BindingContext as DictionaryModel;
    theViewCell.ContextActions.Clear();

    if (item != null) {
        MenuItem mn = new MenuItem();
        mn.Clicked += Menu_Clicked;
        mn.Text = "Delete";
        mn.IsDestructive = true;
        mn.CommandParameter = item.Id;
        theViewCell.ContextActions.Add(mn);
    }
}

private async void Menu_Clicked(object sender, EventArgs e) {
    var mi = ((MenuItem)sender);
}

Happy coding!

Microsoft releases its Common Data Model database to testers

Microsoft has made a promised public preview of its Common Data Model (CDM) entity database available to testers. CDM is at the heart of the coming Microsoft Dynamics 365 bundle.

microsoft-commondatamodel

Microsoft made the promised public preview of its Common Data Model database available on August 8.

The Common Data Model, which Microsoft describes as "an out-of-box business database for storing and managing business entities," is at the center of its PowerApps service for building custom business apps and the coming Dynamics 365 ERP/CRM cloud bundle.

CDM can be used today as a business database for flows created with Microsoft's Flow event-automation tool. CDM can provide access to standard entities, plus allow developers to build custom entities. Microsoft is providing some templates to help users get started.

Users will be able to use CDM to collect data, such as Tweets or RSS items. They also can import and export data from services like Dynamics CRM, Salesforce.com, Excel, and Microsoft's SQL database (cloud and on-prem). They also have the option to use CDM to build and store history/status of pending approvals.

The CDM is meant to provide a database of entities that are common across industry domains, like Sales, Purchase, Customer Service, and Productivity. These entities will connect to Microsoft's first-party business applications, as well as third-party and customer-developed apps.

The entities in CDM will support data types like Address, Email, Currency, Invoice and Order Auto Numbering, images, geographic locations, and more. They'll be implemented using the latest SQL Server data types.

The CDM will be at the heart of Microsoft's Dynamics 365 cloud bundle, the first pieces of which will be available this fall.

Android.Content.Res.Resources+NotFoundException: Resource ID #0x0

I've just created a simple MasterDetailPage and in the code I inserted an icon for the left page with:

public MainPage() {
    InitializeComponent();

    BackgroundColor = Color.FromHex("#007acc");
    Icon = "settings.png";
}

I tried to deploy my app on an Android emulator but I can't deploy it because Android.Content.Res.Resources+NotFoundException: Resource ID #0x0.

I checked everthing and evething seemed fine. The problem is the icon!

You have to remove Icon from the code and in the XAML page type the following code:

  <ContentPage.Icon>
    <OnPlatform x:TypeArguments="FileImageSource">
      <OnPlatform.iOS>settings.png</OnPlatform.iOS>
    </OnPlatform>
  </ContentPage.Icon>

Happy coding!

How to deploy an Universal Windows Project on real device mobile?

I'm trying to debbuging my app on real device (lumia 830 with windows 10 mobile 10.0.10581.0) Developer Mode is ON on both devices (mobile and PC), but when I'm deploying my app on my device I've got an error (DEP6100 and DEP6200). Howevere i can easily emulate on emulators and my PC, couldn’t understand whats the problem.

I googled a bit and I discovered how to resolve the problem.

Visual-Studio-2105-Deploy-Real-Device

  • Create a Registry Key in: [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SirepClient] (Probably you will need to create it)
  • Create a dword with name "DisableProtocol3" and value 00000001
  • Restart Visual Studio and try deploying the solution back again.

It's a provisional solution meanwhile a patch is included in Windows 10 mobile. We will have to consider deleting this key after that.

If you want to inspect your device, connect your device via USB and open a browser and type

https://127.0.0.1:10443

And you can watch your device in action!

Windows 10 Device – Home

Windows-10-Device-Home

Windows 10 Device – App Manager

Windows-10-Device-AppManager

Windows 10 Device – File Explorer

Windows-10-Device-FileExplorer

Windows 10 Device – Processes

Windows-10-Device-Processes

Windows 10 Device – Performances (in real time!)

Windows-10-Device-Performances

Windows 10's Anniversary Update is now available

Windows10-Anniversary

Microsoft's Windows 10 Anniversary Update is here and ready to download. The software maker first started testing its Anniversary Update back in December, and now all Windows 10 users get to experience the new features and improvements free of charge. Chief among them is a new Windows Ink feature. Microsoft has supported inking in Windows for years, but Windows Ink is a dedicated hub designed for devices like the Surface Pro 4, and other 2-in-1s with styluses. Windows Ink will work with your fingers, for doodling and inking on screenshots, but it will obviously work better with a dedicated stylus.

Windows 10 Anniversary Update also includes a number of UI improvements to the Start menu, notification center, taskbar, and overall dark theme. Microsoft is also tweaking Cortana to allow the digital assistant to work on the lock screen and answer queries. If you're a fan of Microsoft's Edge browser, it's also getting extension support today. Extensions like LastPass, 1Password, AdBlock, and EverNote are all available, and more should arrive in the Windows Store in the coming months. Windows 10 Anniversary Update is available from Windows Update immediately, an ISOs are also available (or an easy clean install tool) if you're interested in clean installing the update to your system.

Visual Studio updates Xamarin

When you open Visual Studio 2015 and there is a pop windows to invite you to click on it for updating Xamarin and you click, nothing happends. There is a bug but clicking the update available popup was fixed in one of the recent releases. You can manually update in the Options menu under Tools.

As for the errors, I get those all the time. Support packages can often be a problem. Update to the latest XF package. Try deleting bin, obj, and the contents of packages folders and rebuild.

Visual-Studio-Update-Xamarin

Start Edge Animate when is in the screen

I've come across a few sites that will tie window scrolling with animation. When used in a subtle, small fashion, this is kind of cool. When used to change large portions of the view or really screw with scrolling, I detect it. Like most things, it all comes down to how you use it I suppose. But I was thinking recently - how can we do this with Edge Animate?

Change edgePreload.js

In a file calles something_edgePreload.js you find a line similar to the follow:

    if (AdobeEdge.bootstrapLoading) { 
        signaledLoading = true; 
        AdobeEdge.loadResources = doLoadResources; 
        AdobeEdge.playWhenReady = playWhenReady; 
    }

Replace playWhenReady with false.

Change edgeActions.js

First of all you have to insert a function to decide if an element is in the visible part of the screen.

function isScrolledIntoView(elem) {
    var docViewTop = $(window).scrollTop();
    var docViewBottom = docViewTop + $(window).height();

    var elemTop = $(elem).offset().top;
    var elemBottom = elemTop + $(elem).height();

    return ((elemBottom <= docViewBottom) 
            && (elemTop >= docViewTop));
}

This function returns True if an element is in a visible portion of the screen.

Now we have to change the main function to check it and then play the animation. Here the complete code of an edgeAction.js.

(function($, Edge, compId){
var Composition = Edge.Composition, Symbol = Edge.Symbol; 
   // aliases for commonly used Edge classes

   //Edge symbol: 'stage'
   (function(symbolName) {
       var showAnimation = true;
       function isScrolledIntoView(elem) {
            var docViewTop = $(window).scrollTop();
            var docViewBottom = docViewTop + $(window).height();

            var elemTop = $(elem).offset().top;
            var elemBottom = elemTop + $(elem).height();

            return ((elemBottom <= docViewBottom) 
                    && (elemTop >= docViewTop));
      }

      Symbol.bindSymbolAction(compId, symbolName, 
                    "creationComplete", function(sym, e) {
          var animSize = sym.getDuration();

          if(!isScrolledIntoView('.EDGE-1931783')) {
	        setTimeout(function() { sym.stop(); }, 0);    
          }

           window.onscroll = function(e) {
              if(isScrolledIntoView('.EDGE-1931783')) {
                  if (showAnimation) {
                    sym.play(0);
                    showAnimation = false;
                  }
              }
          }
      });
   })("stage");
   //Edge symbol end:'stage'

})(jQuery, AdobeEdge, "EDGE-1931783");

EDGE-1931783 is the class of my animation. Replace it with yours.

Happy coding!

Microsoft REST API Design Guidelines

Microsoft is publishing its “REST API Design Guidelines” to the API community: http://www.GitHub.com/microsoft/api-guidelines/.

These guidelines represent a multi-year, cross-company, collaborative process aggregating the collective experience of hundreds of engineers designing, operating, and running global scale cloud services from across Microsoft; and listening to feedback on our APIs from customers and partners.  We have attempted to incorporate those learnings along with industry best practices in the API space to create guidelines that API teams across Microsoft use on a daily basis.

Our hope in publishing these guidelines to the greater API community is twofold:

  • First, that we will further stimulate feedback on our APIs and our approach to building them – only through such feedback can we build products that match the evolving needs of our customers.
  • Second, as we have benefitted from others in the API design community who have shared their guidelines, we want to contribute back. We believe that organizations of almost any size building APIs can benefit from having their own design guidelines.  Many companies and even organizations such as the Whitehouse have already published their design guidelines and it’s our hope that by contributing ours to the community conversation, we can add to the body of community knowledge and reusable content so that anyone can draw upon more collective knowledge when looking to set standards and guidelines within their organization.

We recognize that in API design, there are multiple correct ways to do things (ex: snake-case vs. train_case vs. UpperPascalCase vs. …) and we are sharing these design guidelines as what we have settled-upon after much debate among Microsoft colleagues.  We expect that these guidelines will evolve over time and that your feedback will play a part in that evolution.

Origins

Naturally, the Microsoft REST API Guidelines document on GitHub went through a number of iterations before being what you can read today.

The effort got started from hearing two key points of feedback from customers:

  • It should be easier to get started with Microsoft APIs – Developers wanted to be able to run the curl tool against an API endpoint and get a human-readable result in just a few minutes
  • APIs for Microsoft cloud services should be consistent – Developers didn’t care that an API to work with an Azure virtual machine and an API to work with a user’s Office 365 documents were developed by different parts of the company, they were both from Microsoft and developers expected consistency.

One of the goals of the effort was to find the right balance of detail in the guidelines.  We wanted a document that sufficiently codified best practices, but was also approachable for individual contributor engineers and technical product/program managers. 

Relationship with OData

The OASIS Open OData standard provides a great level of detail for API developers seeking wire-level interoperability; and while Microsoft teams are encouraged to follow OData (and benefit from the broad OData ecosystem), there are some cases where it was more specificity than teams needed and some cases where additional information was needed.  For any areas of deviation, we have worked to feed information back to the OASIS OData Technical Committee and many aspects of the latest OData v4.0 and OData v4.01 incorporate learnings from evolution of the Microsoft REST API Guidelines.

Relationship with the Open API Initiative (OAI)

We are proud that Microsoft is a member of the Open API Initiative (OAI), the evolution of Swagger.  As the scope of OAI/Swagger efforts have expanded from a framework and tooling to also include a specification, we believe there are more opportunities ahead for Microsoft colleagues to engage with the OAI community to continue to evolve both.

Installing Google Play Services in the Microsoft Visual Studio Android Emulator

Installing the Google Play Services in Microsoft’s Visual Studio Android Emulator that comes with Visual Studio 2015 is easy to do. This installs the Google Play store and related services, which makes it possible to install other apps to your Android image.

  1. Download the Google Apps package from the Team Android site. Make sure that you match the version of the apps to the version of Android that your emulator is for. The default emulator is for Kit Kat, but this also works for Lollipop.
  2. Start the Microsoft Visual Studio Android Emulator
  3. Start the Android virtual machine that matches the version of the apps that you downloaded for (default would be Kit Kat).
  4. Unlock the Android VM so you get to the home screen
  5. Drag and drop the downloaded Google Apps package in to the Android VM. You will get a prompt to install the apps that looks like this: Install-Goople-Play-Microsoft-Android-Emulator
  6. Select the “Install and Shut Down” option.
  7. Start the VM again
  8. Click the All Apps button in Android and you will see the Google Play store.
  9. When you open the Google Play store, you will need to login with your Google account and make a new one.

Once you have the Google Play store installed, you should be able to install other common applications. I tested this by installing Chrome and it worked well.

Microsoft Orleans

Microsoft-Orleans

Orleans is a framework that provides a straightforward approach to building distributed high-scale computing applications, without the need to learn and apply complex concurrency or other scaling patterns. It was created by Microsoft Research and designed for use in the cloud.

Orleans has been used extensively in Microsoft Azure by several Microsoft product groups, most notably by 343 Industries as a platform for all of Halo 4 and Halo 5 cloud services, as well as by a growing number of other companies.

Scalable by Default
Orleans handles the complexity of building distributed systems, enabling your application to scale to hundreds of servers.
 
Low Latency

Orleans allows you to keep the state you need in memory, so your application can rapidly respond to incoming requests.

Simplified Concurrency
Orleans allows you to write simple, single threaded C# code, handling concurrency with asynchronous message passing between actors.

Advertsing

125X125_06

Planet Xamarin

Planet Xamarin

Calendar

<<  July 2017  >>
MonTueWedThuFriSatSun
262728293012
3456789
10111213141516
17181920212223
24252627282930
31123456

View posts in large calendar

Month List