Ejemplo n.º 1
0
        private void SetIcon(Abstractions.IconEntry view)
        {
            if (!string.IsNullOrEmpty(view.Icon))
            {
                //var resId = Resources.GetIdentifier(view.Icon,"drawable", PackageName)
                //var resId = (int)typeof(Resource.Drawable).GetField(Path.GetFileNameWithoutExtension(view.Icon)).GetValue(null);

                try
                {
                    //Context context => CrossCurrentActivity.Current.Activity;

                    var context = App.Application.Context;
                    var resId   = context.Resources.GetIdentifier(Path.GetFileNameWithoutExtension(view.Icon), "drawable", context.PackageName);
                    if (resId != 0)
                    {
                        Control.SetCompoundDrawablesWithIntrinsicBounds(resId, 0, 0, 0);
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }
            else
            {
                Control.SetCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0);
            }
        }
Ejemplo n.º 2
0
 private void SetIcon(Abstractions.IconEntry view)
 {
     if (!string.IsNullOrEmpty(view.Icon))
     {
         Control.LeftViewMode = UITextFieldViewMode.Always;
         Control.LeftView     = new UIImageView(UIImage.FromBundle(view.Icon));
     }
     else
     {
         Control.LeftViewMode = UITextFieldViewMode.Never;
         Control.LeftView     = null;
     }
 }
Ejemplo n.º 3
0
        private void SetIcon(Abstractions.IconEntry view)
        {
            if (!string.IsNullOrEmpty(view.Icon))
            {
                var ib = new ImageBrush
                {
                    ImageSource = new BitmapImage
                    {
                        UriSource = new Uri($"ms-appx:///Assets/{view.Icon}")
                    },
                    Stretch    = Stretch.None,
                    AlignmentX = AlignmentX.Left
                };
                Control.Background = ib;

                //Should merge IconEntryStyle in Application Resource Dictionaries firstly
                var style = Windows.UI.Xaml.Application.Current.Resources["IconTextBoxStyle"];
                if (style != null)
                {
                    Control.Style = (Windows.UI.Xaml.Style)style;
                }
            }
        }