Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all 91519 articles
Browse latest View live

Style.Triggers TargetType="Button" Property="IsEnabled"

$
0
0

Hello,

I wanted to give a new try to Triggers to avoid using converters / VisualState / CustomRenderer.

I got a ListView filled with data which contains several buttons. Those buttons have their IsEnabled property binded and they use a style which use a Trigger to change the TextColor / Opacity / BackgroundColor to show to user that a button is either available or not.

It doesn't seems to work as I expect.

Here is the style :
<Style x:Key="ContextualCellButtonStyle" TargetType="Button">
<Style.Triggers>
<Trigger TargetType="Button" Property="IsEnabled" Value="False">
<Setter Property="Text" Value="IsEnabled=False" />
<Setter Property="TextColor" Value="Green" />
<Setter Property="BackgroundColor" Value="Red" />
</Trigger>
<Trigger TargetType="Button" Property="IsEnabled" Value="True">
<Setter Property="Text" Value="IsEnabled=True" />
<Setter Property="TextColor" Value="Red" />
<Setter Property="BackgroundColor" Value="Green" />
</Trigger>
</Style.Triggers>
</Style>

(The values used are not the final one, it's just to debug)
As you can see, when a button is enabled, the text should be IsEnabled=True with a green background and red foreground.
If the button is not enabled, the text should be IsEnabled=False with a red background and green foreground.

In my design time model, I've set the first item to enabled and the second one to disabled :

And in my XAML, I have this :

Here is the result I got :

You can see that when the IsEnabled=False, it uses the trigger IsEnabled=True and when the IsEnabled is set to true, I don't have the style I want too.

I guess the Triggers work when the IsEnabled property changes at runtime but I'm not sure. If it is the case, what do you recommend ? A custom control ? A custom renderer ?
I would like to avoid VisualState because I'd like to use MVVM without code behind for this stuff.

I have already written some custom renderer like this but I thought Trigger would be better in this case so I won't have to create a custom control and a custom renderer :

Any help or suggestion is welcomed.
Thanks for reading so far !


How to set binding context with Source={x:reference view } in ResourceDictionary

Xamarin.Forms and NotificationHub; RegisterAsync error

$
0
0

With a Xamarin.Forms app that needs to register with a NotificationHub from the specific platform (in my case Android) I get the error 404 0 2 with message : "The resource you are looking for has been removed, had its name changed, or is temporarily unavailable".

Provided that the NotificationHub was working correctly until few days ago, I suppose that something is not working properly in NotificationHub.

The exception occurs when device needs to register :

var client = new MobileServiceClient(MyApp.App.MobileServiceUrl);
var push = client.GetPush();
await push.RegisterAsync(token, templates); <=================== results in 404 Error

The MobileServiceUrl is an App Service backend connected with the Azure Notification Hub.

Has someone else solved the same problem?

Thanks,

Enrico.

How best to optimise BackgroundColors in a hierarchy of Views when the Colors will be the same?

$
0
0

A ViewModel has a public property that returns the state of some entity.
The View presents that state information in the form of the BackgroundColor (accessibility is taken care of separately).
The ViewModel doesn't know how the View presents the state, so the View uses a ValueConverter to convert the state to the corresponding Color.
All good so far.

The View is made up of a Layout and the Children of that Layout (and any Children or Content of those Children).
The BackgroundColor of the Layout represents the state of the entity.
The BackgroundColor of the Children (and further descendants) of the Layout will also represent the state of the entity, so will be equal to the BackgroundColor of the Layout.

Various implementation methods exist:
(1) The Layout and each of the Children have their BackgroundColor bound to the ViewModel property, each using the ValueConverter. That means lots of repeated conversions.
(2) The Layout has its BackgroundColor bound to the ViewModel property, and each of the Children have their BackgroundColor set to Color.Transparent. So, only one conversion and a lot of Transparent colors.
(3) The Layout has its BackgroundColor bound to the ViewModel property, and each of the Children have their BackgroundColor bound to the Layout's BackgroundColor
(4) Any others?

So, the question is - without breaking MVVM, which would be expected to be the most performant implementation?

What's the best way to expose a Model object in a ViewModel?

$
0
0

Hi developers ! :smile:

I'm begginer into xamarin development and also consider myself as beginner programmist. For some time i'm trying to refactor my app which i wrote first without any design approach or deeper thinking about adding more features to it. Now i face a problem with applying mvvm design pattern which i want to learn before i will start to looking for some internship. I read many tutorials (10 pages next in google ) seen about 50 tutorials on youtube :cold_sweat: and all of them are missing one important thing for me or i just not understoodem well.I tired to expose my model in view model but i don't figure it out how to do it properly becouse i still seeing on output console that my command hasn't found a property bound to it.

How to expose model properties in view model to be able to menage them in view model. ? I want to be able at least increasing one property value of my object by command in view model ? How to menage with this problem ? If you have some links or any your explanation i would be very greatefull for that or just sample example. Any help very appreciate. :smile:
I tired to expose my model in view model but i don't figure it out how to do it properly becouse i still seeing on output console that my command hasn't found a property bound to it.

My final tried before asking here :

        public Waste _wasteModel {
            get
            {
                return _waste;
            }
            set
            {
                _waste = value;
                OnPropertyChanged();
            }
        }

public double Counter
        {
            get
            {
                return _waste.Counter;
            }
            set
            {
                _waste.Counter = value;
                OnPropertyChanged();
            }
        }

Provisioning profiles in visual studio 2017

$
0
0
Hello experts

I have a problem with my new provisioning profile created in the apple developer portal I can see it in the Xcode but no in visual studio I already reconnect the Mac server I don’t know why the profile don’t show up

Thanks in advance.

Adding TextChanged event to an Entry view is crashing whole XAML?

$
0
0

If I remove the event, all is well. Any explanation? Any resolution?

Custom context menu for ViewCell


Xamarin Forms Listview Example

$
0
0

I am fairly new to xamarin and I am trying to create a list view, using xamarin forms and mvvmcross.
I am trying to follow a tutorial I found online, I can't give the link yet.
This gave an error because he, set the binding context to his viewmodel.
But my viewmodel has parameters, I used a prebuilt template, and I can't pass them from the page code.

His code:

public partial class CarsPage : ContentPage {

    public CarsPage() {

        InitializeComponent();

        // Connecting context of this page to the our View Model class
        BindingContext = new CarsViewModel(); // it crashes on this line in my code.
    }

}

My viewmodel code:

    private MvxObservableCollection<VoorwerpItem> voorwerpen;
    public MvxObservableCollection<VoorwerpItem> Voorwerpen
    {
        get { return Voorwerpen; }
        set
        {
            Voorwerpen = value;
        }
    }


    public MainViewModel(IMvxNavigationService navigationService, IMvxLogProvider mvxLogProvider, Services.IAppSettings settings, IUserDialogs userDialogs)
    {
        this.navigationService = navigationService;
        this.mvxLogProvider = mvxLogProvider;
        this.settings = settings;
        this.userDialogs = userDialogs;

        this.log = mvxLogProvider.GetLogFor(GetType());

        Voorwerpen = new MvxObservableCollection<VoorwerpItem>()
        {
             new VoorwerpItem() { Name = "Fiets E", Type = "fiets" }
        };

    }

I have search a lot online trying to find a example of a listview with forms and mvvmcross that works.
However I have been unsuccesfull so far.
How can I have a listview with mvvmcross?
Any example or derication is much appreciated.
I am sorry for not being able to give an better question.

SetBinding in Image with ListView and CustomCell

$
0
0

Hi guys, I want to make a ListView that the image from each item depends on the type of item like the image below:

Now I'm using a CustomCell for the listview :

     public class PlaceCustomCell:ViewCell
        {
            public PlaceCustomCell()
            {
                var nameLabel = new Label
                {
                    FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label)),
                    FontAttributes = FontAttributes.Bold
                };
                nameLabel.SetBinding(Label.TextProperty, new Binding("name"));

                var placeImage = new Image
                {
                    Source = "icon.png",
                    HeightRequest = 48,
                    WidthRequest = 48,
                    Aspect = Aspect.Fill
                };

                View = new StackLayout
                {
                    Orientation = StackOrientation.Horizontal,
                    HorizontalOptions = LayoutOptions.StartAndExpand,
                    Padding = new Thickness(15, 5, 5, 15),
                    HeightRequest = 75,
                    Children = {
                        new StackLayout {
                            Orientation = StackOrientation.Horizontal,
                            Children = { placeImage, nameLabel }
                        }
                    }
                };
            }
        }

Should I use setBinding for the imageSource or can I use another thing?
This code will work for Android and iOS?

Thanks

IOS Submission Rejected Cause of CallKit and CallKit Blocker

$
0
0

Hey everyone,
I have a problem about CallKit and CallKit Blocker. When i submit Xamarin.Forms app to IOS they said :

Guideline 2.3 - Performance - Accurate Metadata
We were unable to locate some of the features described in your metadata.
Specifically, we were unable to locate CallKit and CallKit Blocker features and functionality in the app. /both flags were present in MG during review.

Im not using callkit in my application and Linker Behavior is Link Framework SDKs Only.

Thank you :)

买美国ISU文凭毕业证成绩单加Q微(9105133)爱荷华州立大学毕业证成绩单本科硕士学历/留信认证/使馆认证/真实教育部留服认证Iowa State University

$
0
0

买美国ISU文凭毕业证成绩单加Q微(9105133)爱荷华州立大学毕业证成绩单本科硕士学历/留信认证/使馆认证/真实教育部留服认证Iowa State University

买美国UT文凭毕业证成绩单加Q微(9105133)德克萨斯大学奥斯汀分校毕业证成绩单本科硕士学历/留信认证/使馆认证/真实教育部留服认证University of Texas at Austin

$
0
0

买美国UT文凭毕业证成绩单加Q微(9105133)德克萨斯大学奥斯汀分校毕业证成绩单本科硕士学历/留信认证/使馆认证/真实教育部留服认证University of Texas at Austin

买美国NEU文凭毕业证成绩单加Q微(9105133) 东北大学毕业证成绩单本科硕士学历/留信认证/使馆认证/真实教育部留服认证Northeastern University

$
0
0

买美国NEU文凭毕业证成绩单加Q微(9105133) 东北大学毕业证成绩单本科硕士学历/留信认证/使馆认证/真实教育部留服认证Northeastern University

买美国OSU文凭毕业证成绩单加Q微(9105133)俄亥俄州立大学毕业证成绩单本科硕士学历/留信认证/使馆认证/真实教育部留服认证The Ohio State University

$
0
0

买美国OSU文凭毕业证成绩单加Q微(9105133)俄亥俄州立大学毕业证成绩单本科硕士学历/留信认证/使馆认证/真实教育部留服认证The Ohio State University


买美国MSU文凭毕业证成绩单加Q微(9105133)密歇根州立大学毕业证成绩单本科硕士学历/留信认证/使馆认证/真实教育部留服认证Michigan State University

$
0
0

买美国MSU文凭毕业证成绩单加Q微(9105133)密歇根州立大学毕业证成绩单本科硕士学历/留信认证/使馆认证/真实教育部留服认证Michigan State University

买美国PPD文凭毕业证成绩单加Q微(9105133)培普丹大学毕业证成绩单本科硕士学历/留信认证/使馆认证/真实教育部留服认证Pepperdine University

$
0
0

买美国PPD文凭毕业证成绩单加Q微(9105133)培普丹大学毕业证成绩单本科硕士学历/留信认证/使馆认证/真实教育部留服认证Pepperdine University

买美国NYIT文凭毕业证成绩单加Q微(9105133)纽约理工学院毕业证成绩单本科硕士学历/留信认证/使馆认证/真实教育部留服认证New York Institute of Technology

$
0
0

买美国NYIT文凭毕业证成绩单加Q微(9105133)纽约理工学院毕业证成绩单本科硕士学历/留信认证/使馆认证/真实教育部留服认证New York Institute of Technology

买美国SBU文凭毕业证成绩单加Q微(9105133)纽约州立大学石溪分校毕业证成绩单本科硕士学历/留信认证/使馆认证/真实教育部留服认证Stony Brook University

$
0
0

买美国SBU文凭毕业证成绩单加Q微(9105133)纽约州立大学石溪分校毕业证成绩单本科硕士学历/留信认证/使馆认证/真实教育部留服认证Stony Brook University

买美国SUNY文凭毕业证成绩单加Q微(9105133)纽约州立大学毕业证成绩单本科硕士学历/留信认证/使馆认证/真实教育部留服认证State University of New York SUNY

$
0
0

买美国SUNY文凭毕业证成绩单加Q微(9105133)纽约州立大学毕业证成绩单本科硕士学历/留信认证/使馆认证/真实教育部留服认证State University of New York SUNY

Viewing all 91519 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>