bitfoundation / bitplatform

Build all of your apps using what you already know and love ❤️
https://bitplatform.dev
MIT License
1.08k stars 225 forks source link

How Can Selected Date Value From User And Pass To Code Behind In XAMARIN FORMS #195

Closed alinouri1989 closed 4 years ago

alinouri1989 commented 4 years ago
<bit:BitDateTimePicker
                                CalendarSystem="{x:Static noda:CalendarSystem.PersianArithmetic}"
                                Culture="Fa"
                                DateTimeDisplayFormat="yyyy/MM/dd"
                                AutoClose="True"
                                ShowTimePicker="False"
                                SelectedColor="Black"
                                TodayColor="DeepPink"
                                FlowDirection="RightToLeft"
                                FontFamily="{StaticResource Persian-Solar-Calendar-FontFamily}"
                                Text="Sell Date" />
private void AddHeaderSell_Clicked(object sender, EventArgs e)
        {
            InsertSellHeaderViewModel = new InsertSellHeaderViewModel()
            {
                IdBuyResource = CustomerSell.Id,
                Title = CustomerSell.Name.ToString(),
                DateSell = "Here Got DatePIcker Selected Date By User" // این قسمت توسط تاریخ انتخاب شده در DatePicker تکمیل گردد
                //تاریخ انتخاب شده توسط کاربر داخل این خصیصه قرار داده شود
            };

            SellHeaderCollection = new ObservableCollection<SellHeader>();
            foreach (var item in App.apiServiceManager.InsertHeaderSell(InsertSellHeaderViewModel).Result)
                SellHeaderCollection.Add(item);

            DgvHeaders.ItemsSource = SellHeaderCollection.Select(o => new { o.Id, o.Name, o.DateBuy });

        }
ysmoradi commented 4 years ago

Simply use x:Name on <bit:BitDateTimePicker x:Name="DateSellDateTimePicker" and then in code behind use DateSellDateTimePicker.SelectedDateTime

alinouri1989 commented 4 years ago

CodeBehind Xaml

I Got Error When Use X:Name in i send Error For You

ysmoradi commented 4 years ago

It seems to be an issue with custom namespace schema in xamarin forms Use xmlns:bit="clr-namespace:Bit.View.Controls;assembly=Bit.Client.Xamarin.Controls" instead of xmlns:bit="https://bitframework.com"

I'd recommend you to use MVVM approach. You can also take a look at followings: https://www.dotnettips.info/learningpaths/details/77 Watch this video before reading those articles:

Xamarin-Forms-Bit-Tutorial-Update.zip

alinouri1989 commented 4 years ago

I Like Working MVVM Architecture But I Not Use In All Page ,Tanks Alot, This Name Space Worked For Me, I Replaced xmlns:bit="https://bitframework.com" With xmlns:bit="clr-namespace:Bit.View.Controls;assembly=Bit.Client.Xamarin.Controls"