devnl

Badges

Fourth Anniversary25 LikesThird AnniversaryXamarin Certified Developer5 AnswersFirst AnswerSecond AnniversaryFirst Anniversary5 Likes10 CommentsPhotogenicName DropperFirst Comment

About

Username
devnl
Location
NL
Joined
Visits
434
Last Active
Roles
University
Points
88
Badges
13

devnl ✭✭

About

Username
devnl
Location
NL
Joined
Visits
434
Last Active
Roles
University
Points
88
Badges
13
  • Re: How to bind a Command to ListView.ItemTapped

    Out of the box you won't be able to, @adamkemp created an implementation with a custom bindable property:

    https://github.com/TheRealAdamKemp/Xamarin.Forms-Tests/blob/master/RssTest/View/Pages/MainPage.xaml.cs

  • Re: How to bind a Command to ListView.ItemTapped

    Since there's no Command property to bind to we do it this way:

    <ListView ItemsSource="{Binding Items}" SelectedItem="{Binding SelectedItem, Mode=TwoWay}" HasUnevenRows="True" CachingStrategy="RecycleElement" SeparatorVisibility="None">
        <ListView.ItemTemplate>
            <DataTemplate>
                <ViewCell>
                    <Label Grid.Row="0" TextColor="#000000" Text="Test" />
                </ViewCell>
            </DataTemplate>
        </ListView.ItemTemplate>
    

    And in the ViewModel behind that:

    public Item SelectedItem
    {
        get
        {
            return _selectedItem; 
        }
        set
        {
            _selectedItem = value;
    
            if (_selectedItem == null)
                return;
    
            SomeCommand.Execute(_selectedItem);
    
            SelectedItem = null;
        }
    }
    
  • Re: Xamarin forms ToolBar default icon

    To remove the actual app Icon you can use a custom style, something like:

    <style name="Theme.Main" parent="android:style/Theme.Material.Light.DarkActionBar"> <item name="android:icon">@android:color/transparent</item> </style>

    Which you can then set on your MainActivity:

    [Activity(Label = "My app", Theme = "@style/Theme.Main")] public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsApplicationActivity { }

    To get an icon like the one on the right you can use this in the Page.xaml of the page that needs it:

    <ContentPage.ToolbarItems> <ToolbarItem Icon="someicon.png" Command="{Binding SomeCommand}" /> </ContentPage.ToolbarItems>

    The hamburger menu should come with the built in MasterDetailPage which you could use.

  • Re: How to Send SMTP Email Using Xamarin.Forms without user interaction?

    Another option would be to just implement the mail stuff in a web service that sends the actual mails and call that. That way you're independent of the user and their devices.

  • Re: How can I make an integer StaticResource?

    I suppose you should simply put this in your App.xaml:

    <?xml version="1.0" encoding="UTF-8"?> <Application xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="MyProject.App"> <Application.Resources> <ResourceDictionary> <x:Integer x:Key="SomeValue">5</x:Integer> </ResourceDictionary> </Application.Resources> </Application>

    Out of the box though you won't get a App.xaml but only an App.cs (or ProjectName.cs when using Xamarin Studio). To get an App.xaml simply add a new Xaml page to the project and adjust the codebehind class as follows:

    public partial class App : Application { public App() { // Should call InitializeComponent here for it to work. InitializeComponent(); } }

    You should then be able to use it:

    <Grid Padding="{StaticResource SomeValue}"> </Grid>