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

How to bind a ContentView content at run time to dynamically assign views.

$
0
0

Say I've built a component as follows:

<ContentView x:Class="MyView">
    <ContentView.Content>
        <Grid >

and a few others similar....
I'd like to define a page with some dynamic content in a stack layout

<ContentPage>
    <ContentPage.Content>
    <StackLayout>            
            <ContentView Content= "{Binding TestNavVM.CurrentView}"/>

and then in VM code....

public View CurrentView
{
    get{return view;}
    set{view = value;OnPropertyChanged();}
}
...
and 
CurrentView = new MyView();

Of course, it doesn't work, but as this question here suggests it's possible.

So - what am I doing wrong?


Button size is not exactly, BorderRadius is not working

$
0
0

left label code

xaml

<Label x:Name="presentBtn" Text="선물함" FontSize="16" HorizontalOptions="Start"  HorizontalTextAlignment="Center" VerticalTextAlignment="Center" Grid.Column="0" BackgroundColor="#A8D2F1">

c#

presentBtn.HeightRequest = 45.0 * (double)App.ScreenWidth / 720.0;
    presentBtn.WidthRequest = 150.0* (double)App.ScreenWidth / 720.0;

.
.
.

right button code

xaml

        <Button x:Name="ticketBtn" Text="티켓충전" HorizontalOptions="End"  FontSize="16" Clicked="changeTicketCharge" Grid.Column="1" VerticalOptions="CenterAndExpand" BorderRadius="0"/>

c#

        ticketBtn.HeightRequest = 45* (double)App.ScreenWidth / 720.0;
        ticketBtn.WidthRequest = 150* (double)App.ScreenWidth / 720.0;

I make button in xamarin.form and set HeightRequest, WidthRequest.
but button size is not same to setting size.
upper image's two button is same size.
left is label with backgroundcolor, right is button.
but not same size.

and I want not rounded button. just square. but make button rounded auto.
I set BorderRadius=0, but not working.
like upper image.

plz help me

Culture Localization with Xamarin Forms and .Net Standard

$
0
0

I recently converted a localized app from PCL to .Net Standard which is localized with RESX files as described on this page: https://developer.xamarin.com/guides/xamarin-forms/advanced/localization/

After migration I noticed that .Net Standard does no longer need the assistant code to determine the language set on the device under Android and iOS. However, when I additionally to the culture also provide a culture such as en-GB.resx it is not recognized and will always fall back to the more generic language. Any idea how I can get .Net Standard to recognize the culture?

MVVM viewmodel deselect listview item

$
0
0

Is there a way to deselect a listview item in a viewmodel without having to do it in the xaml code behind?

How can I access the ViewCell that was selected in a ListView ItemSelected event?

$
0
0

Hi all,

I'm trying to access the ViewCell that was selected in a ListView.ItemSelected event. I know how the access the ListView itself and the selected object, but I'm trying to access the actual ViewCell that was selected to change its height (either using the Cell.ForceUpdateSize() method or changing the Cell.Height property). I managed to find a sample on the Xamarin website (Dynamic ListView Row Resizing) in which the ViewCell was accessed as the parent (parent of the parent, to be exact) of a clicked Image that was in the ViewCell, but I'm wondering if there's a way of doing that from the ListView.ItemSelected event. I can't seem to find anything in the documentation that fits the bill.

Thank you!

I need to implement login form AD authentication with my ON-Premises and data save into SQL SERVER

$
0
0

Hi,

I need to implement mobile app with local AD with public IP and also save some data into MSSQL Server with public IP

How to update viewmodel based on selected item of listview present in other viewmodel on same page?

$
0
0

I have a page with master viewmodel.This mater viewmodel is having two different view models with which two content views(custom user control) are binded. The first viewmodel A has a listview in it.On item tap command I want to refresh the content of Viewmodel B. Both A and B are part of same page and I have to achieve this using viewmodels only(no page behind calls).
Till now I am able to populate "A" but on item tap(selecting an item), I am not able to refresh the other viewmodel "B".
Any help will be appreciated

Need to highlight the search keyword in the list view results with some style. Any solution?

$
0
0

Hi Team,

In my app, I have a search functionality with listview controller, I need to implement Input text (Search text) words to be some style in Search results listview. For more please check the attached image. Can anybody have solution for this?


How to get selected item in listview using longpress with mr.gestures?

$
0
0

Hi!

I'm try to get an selected item in listview using longpress with mr.gestures but I'm not getting any success.

Could someone give me an example of using with MVVM?

Regards.

An error occurred while sending the PostAsync request on Android

$
0
0

hello World,

I got an issue, when I do a postAsync request on android devices.
I already add Internet permission to the manifest.
But I don't understand, cause my code is working fine on IOS Device.

I'm using VisualStudio for Mac. :neutral:

my Code:
var client = new HttpClient();
client.BaseAddress = new Uri(Url);
HttpContent _Body = new StringContent(Body, Encoding.UTF8, "application/json"); => System.net.WebException Error NameResolutionFailure
response = client.PostAsync(Uri, _Body).Result;
response.EnsureSuccessStatusCode();
string content = await response.Content.ReadAsStringAsync();

source of the exception : mscorlib

stacktrace:
at System.Net.Http.HttpClientHandler+d__63.MoveNext () [0x004ab] in <35658e59c86d40bdbb2ef0bb34b4f0c7>:0
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <657aa8fea4454dc898a9e5f379c58734>:0
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <657aa8fea4454dc898a9e5f379c58734>:0
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <657aa8fea4454dc898a9e5f379c58734>:0
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <657aa8fea4454dc898a9e5f379c58734>:0
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1+ConfiguredTaskAwaiter[TResult].GetResult () [0x00000] in <657aa8fea4454dc898a9e5f379c58734>:0
at System.Net.Http.HttpClient+d__49.MoveNext () [0x000ca] in <35658e59c86d40bdbb2ef0bb34b4f0c7>:0

Hope someone can guide me to resolve this issue
thanks :smile:

How to get selected item in listview using longpress with mr.gestures?

Real Time FCM Database Sync With Xamarin Form

$
0
0

i am able to get the fcm realtime database data in my xamarin forms, but i want when i change the data of my database on fcm it should also change in my xamarin form application, i had seen people doing it with native form, but that approach didn't worked for me,
please help me if you have any solution for it

Problem after updating

$
0
0

I updated my XamarinStudio today and now I get the following error when I try to compile my iOS project.

"The target "_CollectBundleResources" does not exist in the project."

Any thoughts on how to fix this?

I tried to open up an older working copy of the code and I get the same error.

How to call any Navigation.PushPopupAsync from CustomViewCell in Xamarin Form?

$
0
0

I have a ListView and which is having CustomViewCell. CustomViewCell having few buttons.

Button: ShowProfile: This button popup another page. The problem is I don't know how to Navigation.PushPopupAsync in CustomViewCell. I also need to pass current CustomViewCell details in that.

This is example how I use Navigation.PushPopupAsync in another page which is working fine but doesn't work in case of CustomViewCell.

Navigation.PushPopupAsync(new UserProfilePage(new ExtendedProfile(_viewModel.Profile)));

But above code doesn't work in CustomViewCell.

public partial class ProfileListItemViewCell : CustomViewCell
{
    public ProfileListItemViewCell()
    {
        InitializeComponent();
    }

    protected override void OnBindingContextChanged ()
    {
        base.OnBindingContextChanged ();
    }
    private void MenuItemProfile_Clicked(object sender, System.EventArgs e)
    {
        //not working
        Navigation.PushPopupAsync(new UserProfilePage(new ExtendedProfile(_viewModel.Profile)));
    }
}

Please suggest

Selected item BackgroundColor overwrites button BackgroundColor (ListView)

$
0
0

Hello to all.

I have this custom ViewCell:

        <ViewCell>
          <Grid>
              <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="auto"/>
              </Grid.ColumnDefinitions>

              <StackLayout Grid.Column="0" Style="{StaticResource VerticalCenteredStackLayout}">
                <Label Text="{Binding LineNo}"/>
                <Label Text="{Binding Quantity}" />
              </StackLayout>

                <Button Grid.Column="1" Text="Button" BackgroundColor="Red"/>
          </Grid>
        </ViewCell>

And the aspect in iOS is:

However, when I select some item in the list, the background of the item overwrites the background color of the red button:

How can I avoid this? I want to keep the red color in the button once the item has been selected.

Thanks.


How to redirect page ?

$
0
0

I am getting response from API
{
"success": false,
"message": "Whoops..! Some Error Occured !!",
"parameters": ""
}

so I want to check condition on the basis of true or false. If it is true then it should redirect to another page otherwise it will show a message like-- allready register .


public Command PostCommand
{
get
{
return new Command(async () =>
{
var registrationService = new RegistrationServices();
var response= await registrationService.RegisterData(_registrationViewModel);
if (response.success)
{

                   // await NavigationPage.
                }
                else
                {

                }
            });
        }
    }

public async Task<CustomResponse> PostData(RegistrationViewModel t)
{
try
{
using (HttpClient client = new HttpClient())
{
var json = JsonConvert.SerializeObject(t);
HttpContent content = new StringContent(json);
content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
client.DefaultRequestHeaders.Add("A", "true");
var result = await client.PostAsync("http://xxx.xxx.x.xxx/smaxxxxxi/api/Uxxxxls/Usxxxxxn", content);

               return JsonConvert.DeserializeObject<CustomResponse<string>>(result.Content.ReadAsStringAsync().Result);


            }

            //return   false;
        }

Master detail page strange behavior after update

$
0
0

Hi,

Since I updated Xamarin Forms to latest version (2.3.2.127), the detail pages (which are navigation pages) from my master detail, flicker.
Each time I select a different page, the navigation bar disappears and then reappears.
Although when I use PushAsync, the navigationbar stays in place and only the title changes.
Does anyone know how to fix this?

Flicker in Master Detail Navigation

$
0
0

White screen flickers when changing the detail page on Android (as if a whole white screen is painted between the transitions). Previous versions were smooth. (iOS works fine)

The problem is present in every version after 2.3.4.3.270.

Any suggestions? Downgrading Xamarin.Forms in not an option.

Open mobile camera in webview

$
0
0

I'm building an application where i load website in a webview.

On website i open device camera ( take pics etc ) and its working perfectly fine on all browsers but when i load same application in xamarin.forms web view, mobile camera doesn't show up. Any idea what could be the reason ?

Regards
TA

Problem with release, Archive for publishing.

$
0
0

When i try to install in android devices the keystore signing is working well but when i try to Release, Archive for publishing getting error attached below so please help me out.

/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(2,2): Error MSB6006: "jarsigner" exited with code 1. (MSB6006) (AndroidApplication.Droid)

Viewing all 77050 articles
Browse latest View live


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