I have a xaml :
<phone:LongListSelector Name="llsSourceNews" ItemsSource="{Binding SourceNews}">
<phone:LongListSelector.ItemTemplate>
<DataTemplate>
<Grid x:Name="gridNews">
<Grid.RowDefinitions>
<RowDefinition Height="80" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="120"/>
<ColumnDefinition Width="250"/>
<ColumnDefinition Width="40"/>
</Grid.ColumnDefinitions>
<Image Grid.Row="0" Grid.Column="0" Source="{Binding icon}" Stretch="Fill" Height="35" Width="70"></Image>
<TextBlock Grid.Row="0" Grid.Column="1" Text="{Binding Name}" Foreground="White" TextWrapping="Wrap" FontSize="24" VerticalAlignment="Center"></TextBlock>
<Image Grid.Row="0" Grid.Column="2" Source="/Images/Add-New.png" x:Name="imgAdd" Tap="imgAdd_Tap"></Image>
</Grid>
</DataTemplate>
</phone:LongListSelector.ItemTemplate>
</phone:LongListSelector>
and tap event :
private void imgAdd_Tap(object sender, System.Windows.Input.GestureEventArgs e)
{
if(true)
{
this.Visibility = Visibility.Collapsed;
}
}
My problem is : when user tap image,all image is disable.I want to image is disable which is selected.
this in your case refers to the page. If you want to retrieve the image, you have to cast the sender parameter:
private void imgAdd_Tap(object sender, System.Windows.Input.GestureEventArgs e)
{
if(true)
{
var element = (FrameworkElement)sender;
element.Visibility = Visibility.Collapsed;
}
}
Related
I am proceeding further and generating new ticket as it is quite different from this issue How to prevent Editor to go behind the keyboard in Xamarin.Forms?
I have chat page and autosize editor. When user type more than 1-2 lines, Editor expand correctly but it goes behind the keyboard.
However, if user add multiple lines using "return" it works correctly. I think I am missing something in Xaml page to play with Editor and StackLayout.
Please suggest
Please note that I don't use Xam.Plugins.Forms.KeyboardOverlap. To manage layout on keyboard visibility, I use custom stacklayout WrapperStackLayoutRenderer which set bottom padding on appear and disappear of keyboard.
Page Xaml
<ContentPage.Content>
<local1:WrapperStackLayout>
<Grid Margin="0" Padding="0" RowSpacing="0">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="auto"/>
</Grid.RowDefinitions>
<ListView x:Name="MessagesListView"
ItemTemplate="{StaticResource MessageTemplateSelector}"
ItemsSource="{Binding Conversations}"
HasUnevenRows="True"
Margin="0"
Grid.Row="0"
SeparatorVisibility="None"/>
<Grid RowSpacing="1" ColumnSpacing="2" Padding="5" Grid.Row="1" VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="auto" />
</Grid.ColumnDefinitions>
<local1:EditorWithAutoSize x:Name="txtMessage" Text="{Binding SendingText}" TextChanged="EnableSend"/>
<Frame x:Name="SendButton" Grid.Column="1" Margin= "0" Padding="0" HasShadow="false" HeightRequest="25"
BackgroundColor="Transparent" HorizontalOptions="FillAndExpand">
<Frame.GestureRecognizers>
<TapGestureRecognizer Tapped="SendMessage_Click" NumberOfTapsRequired="1" />
</Frame.GestureRecognizers>
<Label Text="Send" x:Name="sendButton" HeightRequest="20"
HorizontalOptions="Center" VerticalOptions="Center"/>
</Frame>
</Grid>
</Grid>
</local1:WrapperStackLayout>
</ContentPage.Content>
EditorWithAutoSize
public class EditorWithAutoSize : Editor
{
public EditorWithAutoSize()
{
this.TextChanged += (sender, e) => {
this.InvalidateMeasure();
};
}
}
WrapperStackLayout
public class WrapperStackLayout : StackLayout
{
}
WrapperStackLayoutRenderer
public class WrapperStackLayoutRenderer : VisualElementRenderer<StackLayout>
{
public WrapperStackLayoutRenderer()
{
UIKeyboard.Notifications.ObserveWillShow((sender, args) =>
{
if (Element != null)
{
Element.Margin = new Thickness(0, 0, 0, (args.FrameEnd.Height));
}
});
UIKeyboard.Notifications.ObserveWillHide((sender, args) =>
{
if (Element != null)
{
Element.Margin = new Thickness(0); //set the margins to zero when keyboard is dismissed
}
});
}
}
You have to add RowDefinition Height="auto" in your second Grid, then the editor will auto group with the text you entered:
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>
</Grid.RowDefinitions>
The complete code should be:
<Grid RowSpacing="1" ColumnSpacing="2" Padding="5" Grid.Row="1" VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand">
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="auto" />
</Grid.ColumnDefinitions>
<local:EditorWithAutoSize x:Name="txtMessage" Text="Binding SendingText" />
<Frame x:Name="SendButton" Grid.Column="1" Margin= "0" Padding="0" HasShadow="false" HeightRequest="25"
BackgroundColor="Transparent" HorizontalOptions="FillAndExpand">
<Label Text="Send" x:Name="sendButton" HeightRequest="20"
HorizontalOptions="Center" VerticalOptions="Center"/>
</Frame>
</Grid>
I uploaded my test sample here and you can check it: editor-xamarin.forms
BTW, there is a sample in github that you can refer: ChatUIXForms, you can use the editor and custom renderer code in his project. There are also blogs the author wrote you can read.
On the click of image inside a List view ,I want Like to hide a Grid which is in ListView.GroupHeaderTemplate. I have made Bindings also- IsVisible="{Binding ShowGrid}" on that Grid. I have taken Reference from https://stackoverflow.com/a/55274297/10223206 this post .But Struck , Visibility is not Changing . I am Sharing my Code for better understanding
View Model-
private bool _ShowGrid = false;
public bool ShowGrid
{
get => _ShowGrid;
set
{
_ShowGrid = value;
RaisePropertyChanged();
}
}
In cs:_(Image Tap-Image Name - downarrow.png)
private void TapGestureRecognizer_Tapped_1(object sender, EventArgs e)
{
try
{
Image image = sender as Image;
string source = image.Source as FileImageSource; //Getting the name of source as string
if (String.Equals(source, "downarrow.png"))
{
image.Source = "uparrow.png";
viewModel.ShowGrid = false;
}
else
{
image.Source = "downarrow.png";
viewModel.ShowGrid = true;
}
}
catch(Exception ex)
{
var m = ex.Message;
}
}
Xaml-
<ListView x:Name="MyListView" IsGroupingEnabled="true" Footer=" "
HasUnevenRows="True" ItemSelected="MyListView_ItemSelected"
SeparatorColor="Transparent" VerticalOptions="FillAndExpand"
SeparatorVisibility="None" >
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<Grid IsVisible="{Binding ShowGrid}" >
<Grid RowSpacing="0">
<Grid.RowDefinitions>
<RowDefinition Height="40" />
</Grid.RowDefinitions>
<Image Grid.Column="0" Aspect="AspectFit" HeightRequest="20" WidthRequest="30"
HorizontalOptions="CenterAndExpand"
VerticalOptions="CenterAndExpand"
Source="checked.png" />
<Label Grid.Column="1" Text="{Binding SatusName}" FontSize="10"
HorizontalOptions="StartAndExpand"
VerticalOptions="CenterAndExpand" />
<Label Grid.Column="2" Text="{Binding Date}" FontSize="10"
HorizontalOptions="StartAndExpand"
VerticalOptions="CenterAndExpand" />
</Grid>
</Grid>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
<ListView.GroupHeaderTemplate>
<DataTemplate>
<ViewCell>
<Grid RowSpacing="0" ColumnSpacing="0">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="50"/>
</Grid.ColumnDefinitions>
<Label Grid.Row="0" Grid.Column="0" VerticalOptions="CenterAndExpand"
Text="{Binding personName}" TextColor="{StaticResource PrimaryBlue}"
FontSize="Medium" FontAttributes="Bold"/>
<Label Grid.Row="0" Grid.Column="1"
Text="{Binding Amount}" VerticalOptions="CenterAndExpand"
TextColor="{StaticResource PrimaryBlue}"
FontSize="Medium" />
<Image Source="downarrow.png" Grid.Row="0" Grid.Column="2" x:Name="ArrowImage"
HeightRequest="20" WidthRequest="30"
HorizontalOptions="EndAndExpand" VerticalOptions="StartAndExpand" >
<Image.GestureRecognizers>
<TapGestureRecognizer Tapped="TapGestureRecognizer_Tapped_1"/>
</Image.GestureRecognizers>
</Image>
</Grid>
</ViewCell>
</DataTemplate>
</ListView.GroupHeaderTemplate>
But Nothing Seems Work , it not hiding Grid on IMAGE CLICK. Kindly help me find a Solution.
.cs
grouped = new ObservableCollection<GroupedOrderModel>();
var person1Group = new GroupedOrderModel() { personName = "Personal loan" ,Amount="100"};
var person2Group = new GroupedOrderModel() { personName = "Car Loan",Amount="300" };
var person3Group = new GroupedOrderModel() { personName = "Rent Loan",Amount="400" };
person1Group.Add(new StaffLoanStatus() { SatusName = "Approved", Date = "23-01-2019" });
person1Group.Add(new StaffLoanStatus() { SatusName = "Pending", Date = "20-01-2019" });
person1Group.Add(new StaffLoanStatus() { SatusName = "Declined", Date = "19-01-2019" });
person2Group.Add(new StaffLoanStatus() { SatusName = "Approved", Date = "23-01-2019" });
person2Group.Add(new StaffLoanStatus() { SatusName = "Pending", Date = "20-01-2019" });
grouped.Add(person1Group);
grouped.Add(person2Group);
//Person3 without OrderModel
grouped.Add(person3Group);
MyListView.ItemsSource = grouped;
The reason is not working is the BindingContext since ListViews ItemsSource is it binding context anything outside it is alien to that DataTemplate try doing this:
IsVisible="{Binding Path=BindingContext.ShowGrid, Source={x:Reference MyListView}}"
how can i display 5 items when we scrolling i want load more.
<ListBox.ItemTemplate>
<DataTemplate >
<Border BorderThickness="0,0,0,1" BorderBrush="Black"
HorizontalAlignment="Stretch" Width="400"
Margin="-8,0,-8,0">
<Grid Height="130"
RenderTransformOrigin="0.37,0.52">
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>
<RowDefinition Height="auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Grid HorizontalAlignment="Left"
Height="104"
Grid.Row="0"
VerticalAlignment="Top"
Width="115" Background="White"
Margin="05,-4,0,0">
<Image Source="{Binding company_logo}" Stretch="None"
Margin="10,0,0,0"/>
</Grid>
<Grid Height="104" HorizontalAlignment="Right"
Grid.Row="0"
VerticalAlignment="Top" Width="280"
Background="White" Grid.ColumnSpan="2">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="3*"/>
<ColumnDefinition Width="307*"/>
</Grid.ColumnDefinitions>
<TextBlock HorizontalAlignment="Left"
Margin="0,0,0,0"
TextWrapping="Wrap"
Text="{Binding product_name}"
VerticalAlignment="Top"
FontSize="20"
Foreground="Orange"
Grid.Column="1"/>
<TextBlock Text="Reviews:"
Margin="97.5,27,125,51"
Grid.Column="1"/>
<TextBlock HorizontalAlignment="Left"
Margin="145,30,0,0"
TextWrapping="Wrap"
Text="{Binding product_reviews}"
VerticalAlignment="Top"
FontSize="10" Width="50"
Foreground="Orange"
Grid.Column="1"/>
<TextBlock Text="Rating:" FontSize="15"
Margin="0,25,232,51"
Grid.Column="1"/>
<TextBlock HorizontalAlignment="Left" Margin="50,30,0,0"
TextWrapping="Wrap" Text="{Binding product_rating}"
VerticalAlignment="Top" FontSize="10"
Foreground="Black" Grid.Column="1"/>
<Image Source="Assets/clock-icon.png" Margin="165,25,0,0" Width="25" Height="25"/>
<TextBlock Text="Created Date" FontSize="10"
Margin="155,29,70,62" Foreground="Red"
Grid.Column="1"/>
<TextBlock HorizontalAlignment="Left" Width="59"
Margin="218,29,0,0"
TextWrapping="Wrap"
Text="{Binding created_date}"
VerticalAlignment="Top" FontSize="10"
Foreground="Black"
Grid.Column="1" Height="13">
</TextBlock>
<TextBlock Text="Updated Date:" FontSize="10"
Margin="155,39,70,52" Foreground="Red"
Grid.Column="1"/>
<TextBlock HorizontalAlignment="Left" Width="59"
Margin="218,39,0,0"
TextWrapping="Wrap"
Text="{Binding updated_date}"
VerticalAlignment="Top" FontSize="10"
Foreground="Black"
Grid.Column="1" Height="13">
</TextBlock>
<TextBlock HorizontalAlignment="Left" Margin="3,58,0,0" TextWrapping="Wrap"
Text="{Binding product_description}"
VerticalAlignment="Top" FontSize="10"
Foreground="Black" Height="40"
Width="293" Grid.Column="1" />
</Grid>
<TextBlock HorizontalAlignment="Left" Margin="15,100,0,0"
TextWrapping="Wrap" Width="250"
Text="{Binding companyName}"
VerticalAlignment="Top" FontSize="15"
Foreground="Black"/>
<Button Content="Contact" Foreground="Red"
FontSize="10"
Margin="120,88,-29,440.667"
Height="25" Grid.Column="1"/>
</Grid>
</Border>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
and my code is below
List<products> products1 = new List<products>();
try
{
using (HttpClient client = new HttpClient())
{
client.BaseAddress = new Uri("something");
var url = "data/getProductsData";
Parameters product = new Parameters();
product.user_id = "1";
product.platform = "Android";
string json = JsonConvert.SerializeObject(product);
StringContent queryString = new StringContent(json);
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
HttpResponseMessage response = await client.PostAsync(url, queryString);
if (response.IsSuccessStatusCode)
{
var data = response.Content.ReadAsStringAsync();
Response my = JsonConvert.DeserializeObject<ResponseWrapper>(data.Result.ToString()).response;
LoadingBar.IsEnabled = true;
LoadingBar.Visibility = Visibility.Visible;
var myData =data.Result.ToString();
//await new MessageDiaglog("Data Loaded!").ShowAsync();
LoadingBar.IsEnabled = false;
LoadingBar.Visibility = Visibility.Collapsed;
foreach (var item in my.content.products)
{
products1.Add(item);
}
}
lstbox.ItemsSource = products1;
}
}
catch (Exception ex)
{
MessageDialog message = new MessageDialog(ex.Message);
message.ShowAsync();
first of all :
1- change this line
List<products> products1 = new List<products>();
with this
public static ObservableCollection<products> products1 = new ObservableCollection<products>();
2- get scrolling postion of your listbox
public static ScrollViewer GetScrollViewer(DependencyObject dpj)
{
if (dpj is ScrollViewer) return dpj as ScrollViewer;
for (int i = 0; i < VisualTreeHelper.GetChildrenCount(dpj); i++)
{
var child = VisualTreeHelper.GetChild(dpj, i);
var result = GetScrollViewer(child);
if (result != null)
{
return result;
}
}
return null;
}
3- create a handler of listbox_loaded.
private void lstsource_Loaded(object sender, RoutedEventArgs e)
{
ScrollViewer viewer = GetScrollViewer(this.lstsource);
viewer.ViewChanged += lstSoucrce_ViewChanged;
}
4- on view changed ...
private async void lstSoucrce_ViewChanged(object sender, ScrollViewerViewChangedEventArgs e)
{
var sv = (ScrollViewer)VisualTreeHelper.GetChild(VisualTreeHelper.GetChild(this.lstsource, 0), 0);
var verticaloffset = sv.VerticalOffset;
var maxVerticleOffset = sv.ScrollableHeight;
if (maxVerticleOffset < 0 || verticaloffset == maxVerticleOffset)
{
//this will fired up when you will reach end of list
//load your more data here
}
I have a listview defined like this:
<ListView
x:Name="phonesListView"
Grid.Row="5"
Background="Black"
IsItemClickEnabled="True"
Foreground="Gray" >
<ListView.ItemTemplate>
<DataTemplate>
<Grid Width="auto" HorizontalAlignment="Stretch">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid
Grid.Row="0">
<Grid.ColumnDefinitions >
<ColumnDefinition Width="3*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<ComboBox
Grid.Column="0"
VerticalAlignment="Center"
Background="Black"
Foreground="White">
<ComboBoxItem Content="Home" IsSelected="True"/>
<ComboBoxItem Content="{Binding Type}"/>
<ComboBoxItem Content="Office"/>
<ComboBoxItem Content="Fax"/>
</ComboBox>
<Button
Grid.Column="1"
Height="30"
Width="30"
Foreground="Black"
Margin="0, 5, 0, 5"
HorizontalAlignment="Center" Click="RemovePhone">
<Button.Background>
<ImageBrush Stretch="Fill" ImageSource="Assets/appbar.close.png" />
</Button.Background>
</Button>
</Grid>
<TextBox
Grid.Row="1"
Background="White"
Foreground="Black"
FontSize="20"
InputScope="TelephoneNumber"
Text="{Binding Number}"/>
</Grid>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
I have an private ObservableCollection<Phone> numbers = new ObservableCollection<Phone>();
In constructor I call phonesListView.ItemSource = numbers;
And on some button click I want to add new item to the listView so I call a method:
private void AddPhone(object sender, RoutedEventArgs e) {
Phone phone = new Phone("", Types.HOME);
numbers.Add(phone);
}
But after button click to add a item the app crashes and App.g.i.cs is called and global::System.Diagnostics.Debugger.Break(); is highlighted
#if DEBUG && !DISABLE_XAML_GENERATED_BREAK_ON_UNHANDLED_EXCEPTION
UnhandledException += (sender, e) =>
{
if (global::System.Diagnostics.Debugger.IsAttached) global::System.Diagnostics.Debugger.Break();
};
#endif
I'm really new to Universal Windows App, and I read that this is called when something is wrong with XAML code. Could you help me with that? Thanks.
I tried to use ItemsSource="{x:Bind Mode=TwoWay}"
The only way (but not the best, I think) where I could dynamically update a listview was making a method that handle a button event where I add a new element (calling the addmethod) and updating the ItemsSource property of the list view.
private void AnadeDoctorAppBarButton_Click(object sender, RoutedEventArgs e)
{
Doctor A = new Doctor("Mapache", "dentista", "La calle", "La vida", "Lo que sea", "Direccion", "olos");
ViewModel.AnadeDoctor = A;
ListaDePrueba.ItemsSource = ViewModel.ColeccionDoctores;
}
It Works, but I think that is not true Databinding.
I have a problem selecting an item from a Pivot in Windows Phone 8.1. I have a CommandBar that makes navigation between pages belonging to Pivot, and have programmed change in the onClick SelectedItem of each button and the display changes to each page. When I start the application all the buttons, making debug SelectedItem change is made and no exception but the display does not change page. The strangest thing is that when I navigate manually between pages with navigation Pivot and then pressed a button on the CommandBar pages work. The problem only happens when I start the application.
It can happen ?, As I can solve ?, I'm a little frustrated xD.
Here is the code of Pivot and Command Bar:
<Pivot x:Name="pivotMain" Style="{StaticResource PivotStyleMain}" Margin="0,0,-0.333,0" >
<PivotItem x:Name="pvtMenu" Header="Online" DataContext="{Binding Groups}">
<ListView
AutomationProperties.AutomationId="ItemListViewSection3"
AutomationProperties.Name="Items In Group"
SelectionMode="None"
IsItemClickEnabled="True"
ItemsSource="{Binding lstMenu}"
ItemTemplate="{StaticResource StandardTripleLineItemTemplate}"
ItemClick="ItemView_ItemClick"
ContinuumNavigationTransitionInfo.ExitElementContainer="True">
</ListView>
</PivotItem>
<PivotItem x:Name="pvtMenuOffline" Header="Offline" DataContext="{Binding Groups}">
<ListView
AutomationProperties.AutomationId="itmListViewMenuOffline"
AutomationProperties.Name="Items In Group"
SelectionMode="None"
IsItemClickEnabled="True"
ItemsSource="{Binding lstMenuOffline}"
ItemTemplate="{StaticResource StandardTripleLineItemTemplatePathImage}"
ContinuumNavigationTransitionInfo.ExitElementContainer="True" ItemClick="ListView_ItemClick">
</ListView>
</PivotItem>
<PivotItem x:Name="pvtInfo" Header="InformaciĆ³n">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<ListView>
<TextBlock Height="Auto" Width="Auto" FontSize="25" Foreground="#7D7D7D">EncuƩntranos en</TextBlock>
<Border Background="{ThemeResource ListViewItemPlaceholderBackgroundThemeBrush}" Margin="0,9.5,0,0" Grid.Column="0" HorizontalAlignment="Left">
<Image Source="Assets/fb.png" Stretch="UniformToFill" AutomationProperties.Name="imgFcbk" Height="Auto" Width="300" Tapped="Image_Tapped"/>
</Border>
<Border Background="{ThemeResource ListViewItemPlaceholderBackgroundThemeBrush}" Margin="0,9.5,0,0" Grid.Column="0" HorizontalAlignment="Left">
<Image Source="Assets/tw.png" Stretch="UniformToFill" AutomationProperties.Name="imgFcbk" Height="Auto" Width="300" Tapped="Image_Tapped_1"/>
</Border>
<Border Background="{ThemeResource ListViewItemPlaceholderBackgroundThemeBrush}" Margin="0,9.5,0,0" Grid.Column="0" HorizontalAlignment="Left">
<Image Source="Assets/yt.png" Stretch="UniformToFill" AutomationProperties.Name="imgFcbk" Height="Auto" Width="300" Tapped="Image_Tapped_2"/>
</Border>
</ListView>
<Border Background="Transparent" Grid.Column="0" Grid.Row="1" HorizontalAlignment="Left" Padding="10">
<Image Source="Assets/componetes dispositivos moviles-22.png" Stretch="UniformToFill" AutomationProperties.Name="imgFcbk" Height="Auto"/>
</Border>
</Grid>
</PivotItem>
</Pivot>
</Grid>
<Page.BottomAppBar>
<CommandBar>
<CommandBar.PrimaryCommands>
<AppBarButton x:Name="barBtnHome" Label="Online" Command="{Binding SomeCommand}" IsDoubleTapEnabled="False" IsHoldingEnabled="False" IsRightTapEnabled="False" Click="barBtnHome_Click">
<AppBarButton.Icon>
<BitmapIcon UriSource="Assets/earth53.png"/>
</AppBarButton.Icon>
</AppBarButton>
<AppBarButton x:Name="barBtnOffline" Label="Offline" Command="{Binding SomeCommand}" IsDoubleTapEnabled="False" IsHoldingEnabled="False" IsRightTapEnabled="False" Click="barBtnOffline_Click">
<AppBarButton.Icon>
<BitmapIcon UriSource="Assets/earth85.png"/>
</AppBarButton.Icon>
</AppBarButton>
<AppBarButton x:Name="barBtnAbout" Label="Info" Command="{Binding SomeCommand}" IsHoldingEnabled="False" IsDoubleTapEnabled="False" IsRightTapEnabled="False" Click="barBtnAbout_Click">
<AppBarButton.Icon>
<BitmapIcon UriSource="Assets/appbar.information.circle.png"/>
</AppBarButton.Icon>
</AppBarButton>
</CommandBar.PrimaryCommands>
</CommandBar>
</Page.BottomAppBar>
And here is the code behind the onclick:
private void barBtnHome_Click(object sender, RoutedEventArgs e)
{
this.pivotMain.SelectedItem = this.pvtMenu;
}
private void barBtnAbout_Click(object sender, RoutedEventArgs e)
{
this.pivotMain.SelectedItem = this.pvtInfo;
}
private void barBtnOffline_Click(object sender, RoutedEventArgs e)
{
this.pivotMain.SelectedItem = this.pvtMenuOffline;
}
Much appreciate your help.
User SelectedIndex instead of SelectedItem.
private void barBtnHome_Click(object sender, RoutedEventArgs e)
{
this.pivotMain.SelectedIndex = 0;
}
private void barBtnAbout_Click(object sender, RoutedEventArgs e)
{
this.pivotMain.SelectedIndex = 1;
}
private void barBtnOffline_Click(object sender, RoutedEventArgs e)
{
this.pivotMain.SelectedIndex = 2;
}