Posts

Read Data from Json file

 Step 1  Past json format to text file save as .json Step 2 add file in to pcl Step 3 Right click the file and Select properties Step 4 Change Build action to Embedded Resource Step 5   Add this method to ViewModel private void GetJsonData()         {             try             {                 var _tempdata = new ResponseData();                 string jsonFileName = "gold_sample_response.json";                 var assembly = typeof(CurrentViewModelname).GetTypeInfo().Assembly;                 Stream stream = assembly.GetManifestResourceStream($"{assembly.GetName().Name}.{jsonFileName}");                 using (var reader = new System.IO.StreamReader(stream))   ...

Alter List Item while Binding

Step 1               add needed paramenter to required list step 2              Use that paramenter to bind in list item source --------------------------        if (result.listdata!= null)                             {                                                                 List<TrackList> objlist = new List<TrackList>();                                 foreach (var item in result.listdata)                                 {               ...

Listview SelectedItem in MVVM

Create Helper class named ListViewBehaviours ------------------------------- ListViewBehaviours.cs  public class ListViewBehaviours : Behavior<ListView> { public static readonly BindableProperty CommandProperty = BindableProperty.Create( propertyName: "Command", returnType: typeof(ICommand), declaringType: typeof (ListViewBehaviours)); public ICommand Command { get { return (ICommand)GetValue(CommandProperty); } set { SetValue(CommandProperty, value); } } protected override void OnAttachedTo(ListView bindable) { base.OnAttachedTo(bindable); bindable.ItemSelected += Bindable_ItemSelected; bindable.BindingContextChanged += Bindable_BindingContextChanged; } private void Bindable_BindingContextChanged(object sender, EventArgs e) { var lv = sender as ListView; BindingContext = lv?.BindingContext; } private void Bindable_ItemSelected(object sender, SelectedItemChangedEv...

Button click event with current object from listview having button

 XAML <StackLayout.GestureRecognizers>               <TapGestureRecognizer Command="{Binding Path=BindingContext.OnReadMoreClicked, Source={x:Reference Page}}" CommandParameter="{Binding .}" />  </StackLayout.GestureRecognizers> ----------------------------------- In ViewModel   private Command<object> _onReadMoreClicked;         public Command<object> OnReadMoreClicked         {             get             {return _onReadMoreClicked ?? (_onReadMoreClicked = new Command<object>((currentObject) =>                 GetDetailsforRead(currentObject)                 ));             }         }

SideMenu React native

import React, { Component } from 'react'; import { StyleSheet, Platform, View, Text, Image, TouchableOpacity, YellowBox, Dimensions } from 'react-native'; import { DrawerNavigator } from 'react-navigation'; import { StackNavigator } from 'react-navigation' class HamburgerIcon extends Component {   toggleDrawer = () => {     console.log(this.props.navigationProps);     this.props.navigationProps.toggleDrawer();   }   render() {     return (       <View style={{ flexDirection: 'row' }}>         <TouchableOpacity onPress={this.toggleDrawer.bind(this)} >           <Image             source={{ uri: 'https://reactnativecode.com/wp-content/uploads/2018/04/hamburger_icon.png' }}             style={{ width: 25, height: 25, marginLeft: 5 }}           /> ...

side menu in react native

index import React , { Component } from ' react ' ; import Router from ' ./routes ' ; import { AppRegistry } from ' react-native ' ; export default class CustomDrawer extends Component { render () { return ( < Router / > ); } } AppRegistry . registerComponent ( ' CustomDrawer ' , () => CustomDrawer); ------- import PropTypes from 'prop-types'; import React, {Component} from 'react'; import styles from './SideMenu.style'; import {NavigationActions} from 'react-navigation'; import {ScrollView, Text, View} from 'react-native'; class SideMenu extends Component { navigateToScreen = (route) => () => { const navigateAction = NavigationActions.navigate({ routeName: route }); this.props.navigation.dispatch(navigateAction); } render () { return ( <View style={styles.container}> <ScrollView> ...

Drawer Navigation with Custom Side Menu — React Native

————————— Primary nav import React, { Component } from 'react'; import { AppRegistry, Dimensions } from 'react-native'; import { DrawerNavigator } from 'react-navigation'; import SideMenu from './SideMenu/SideMenu' import stackNav from './app/stacknav'; const drawernav = DrawerNavigator({    Item1: {        screen: stackNav,      }    }, {      contentComponent: SideMenu,      drawerWidth: Dimensions.get('window').width - 120,    }); AppRegistry.registerComponent('Demo', () => drawernav); ——————— SideMenu import PropTypes from 'prop-types'; import React, {Component} from 'react'; import styles from './SideMenu.style'; import {NavigationActions} from 'react-navigation'; import {ScrollView, Text, View} from 'react-native'; import { StackNavigator } from 'react-navigation'; class SideMenu extends Component {    nav...