How to show controls button in windows phone 8.1 map control - maps

Basically I want to show built in controls button like zoom in or zoom out etc in my windows phone 8.1 map control
Like this type of in google maps. Is there any way to do that?
This my map code
<Maps:MapControl MapServiceToken="abcdef-abcdefghijklmno" Grid.Row="1" Margin="10,10,10,10" x:Name="MapControl" >
<Maps:MapItemsControl x:Name="MapIcons">
<Maps:MapItemsControl.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Vertical" >
<Image Source="{Binding picture}" Width="50" Height="50" ></Image>
<TextBlock Maps:MapControl.Location="{Binding Location}" Text="{Binding name}" Foreground="Black" FontSize="15"/>
</StackPanel>
</DataTemplate>
</Maps:MapItemsControl.ItemTemplate>
</Maps:MapItemsControl>
</Maps:MapControl>

Why not just show it above the map, something like this:
<Grid>
<Maps:MapControl ...
<StackPanel HorizontalAlignment="Right" VerticalAlignment="Bottom">
<Button> ...
<Button> ...
<Button> ...
</StackPanel>
</Grid

Related

DataTemplate only shows Canvas for the last record

I'm using the following DataTemplate
<DataTemplate x:Key="platform_resources">
<StackPanel Orientation="Horizontal">
<Viewbox Width="30" Height="30" ToolTip="Network Domain Count" Stretch="Uniform">
<ContentControl DataContext="{Binding}" Focusable="False" Content="{DynamicResource appbar_server}" />
</Viewbox>
<TextBlock Margin="0,7,0,0" Text="{Binding Path=workload_count}"/>
<Separator Style="{StaticResource {x:Static ToolBar.SeparatorStyleKey}}" />
<Viewbox Width="30" Height="30" ToolTip="Logical Network Count" Stretch="Uniform">
<ContentControl Focusable="False" Content="{DynamicResource appbar_network_server_connecting}" />
</Viewbox>
<TextBlock Margin="0,7,0,0" Text="{Binding Path=vlan_count}"/>
<Separator Style="{StaticResource {x:Static ToolBar.SeparatorStyleKey}}" />
<Viewbox Width="30" Height="30" ToolTip="Network Domain Count" Stretch="Uniform">
<ContentControl Focusable="False" Content="{DynamicResource appbar_network}" />
</Viewbox>
<TextBlock Margin="0,7,0,0" Text="{Binding Path=networkdomain_count}"/>
</StackPanel>
</DataTemplate>
The template displays all the relevant data with separators but only shows the images on the last record. It's leaves spaces where the images are supposed to be, but no images.
Make sure you add x:Shared="False" property to your resources.
Example:
<Canvas x:Key="appbar_server" x:Shared="False">
<!-- ... -->
</Canvas>
This happens because you probably defined some Images (e.g appbar_server) in your resources and trying to display them in multiple items. But Image is a Visual and in WPF each Visual can only have one parent. So when your items are being generated, each item steals the Image from the previous one until the last item finally gets it.
Solution:
Unlike Image, BitmapImage is not a Visual and thus can be set multiple times as the source of different items. So instead of defining Images in your Resources, define BitmapImages:
<Window.Resources>
<BitmapImage x:Key="appbar_server" UriSource="C:\...\appbar_server.png"/>
....
And then instead of ContentControls create Image instances in your DataTemplate to present them:
<DataTemplate>
<StackPanel Orientation="Horizontal">
<Viewbox Width="30" Height="30" ToolTip="Network Domain Count" Stretch="Uniform">
<Image Focusable="False" Source="{DynamicResource appbar_server}" />
</Viewbox>
<TextBlock Margin="0,7,0,0" Text="{Binding Path=workload_count}"/>
...
*Update:
The image is captured in a canvas which seems to be needing some
special wrapper to make this work.
In that case, you should define a DataTemplate for each Canvas like this:
<Window.Resources>
<DataTemplate x:Key="appbar_3d_3ds">
<Canvas Width="76" Height="76" Clip="F1 M 0,0L 76,0L 76,76L 0,76L 0,0">
<Path Width="32" Height="40" Canvas.Left="23" Canvas.Top="18" Stretch="Fill" Fill="Black" Data="F1 M 27,18L 23,26L 33,30L 24,38L 33,46L 23,50L 27,58L 45,58L 55,38L 45,18L 27,18 Z "/>
</Canvas>
</DataTemplate>
....
And then create ContentPresenter Instances in your ItemTemplate with their ContentTemplate set to your pre-defined data templates (e.g. appbar_3d_3ds).
<DataTemplate>
<StackPanel Orientation="Horizontal">
<Viewbox Width="30" Height="30" ToolTip="Network Domain Count" Stretch="Uniform">
<ContentPresenter ContentTemplate="{DynamicResource appbar_3d_3ds}"/>
</Viewbox>
<TextBlock Margin="0,7,0,0" Text="{Binding Path=workload_count}"/>
....

Buttons in ListBox

I'm doing a list in my project, that needs a button for each item.
How can I get those buttons in ListBox, like in the page "Last calls" of my windows phone?
Thanks.
FunksMaName answer is very much correct except a Small change.....
<ListBox Height="360"
HorizontalAlignment="Left"
Margin="22,23,0,0"
Name="UserDetailsListBox"
VerticalAlignment="Top"
Width="413"> <ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<Button.Template>
<ControlTemplate>
<Image Source="/Assets/Images/MyImage.png" />
</ControlTemplate>
</Button.Template>
<TextBlock x:Name="txtOverViewHeader1"
Text="OverView"
Foreground="Yellow"
Width="600"
FontSize="28"
Margin="10,0,0,0"
Height="65">
</TextBlock>
</StackPanel>
</DataTemplate></ListBox.ItemTemplate></ListBox>
i just moved image inside button's template instead of content ... That is more accurate..
We may add button for each item of the Listbox like this.
<ListBox Height="360"
HorizontalAlignment="Left"
Margin="22,23,0,0"
Name="UserDetailsListBox"
VerticalAlignment="Top"
Width="413">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Vertical"
>
<StackPanel Orientation="Horizontal">
<Button Width="150" Height="50" x:Name="Btn1" Content="Button1" Margin="0,-20,0,0"/>
<TextBlock x:Name="txtOverViewHeader1"
Text="OverView"
Foreground="Yellow"
Width="600"
FontSize="28"
Margin="10,0,0,0"
Height="65">
</TextBlock>
</StackPanel>
<StackPanel Orientation="Horizontal">
<Button Width="150" Height="50" x:Name="Btn2" Content="Button2" Margin="0,-20,0,0"/>
<TextBlock x:Name="txtOverViewHeader2"
Text="OverView"
Foreground="Yellow"
Width="600"
FontSize="28"
Margin="10,0,0,0"
Height="65">
</TextBlock>
</StackPanel>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
Hope it will give you the desired answer
The easiest way to get round buttons is to user Coding4Fun. It is free to use and very simple to install.
You can follow these instructions to use it in your application.
As for the icons, you can either search around for some free packs or you can see if Metro Studio 2 has the icon you need. That tool is also free to use.
Use a circular image, and set the Tap event, or wrap your image around a Button template if you need a buttons specific behavior
<ListBox Height="360"
HorizontalAlignment="Left"
Margin="22,23,0,0"
Name="UserDetailsListBox"
VerticalAlignment="Top"
Width="413">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<Button Template="x:Null" Tap="">
<Image Source="/Assets/Images/MyImage.png" />
</Button>
<TextBlock x:Name="txtOverViewHeader1"
Text="OverView"
Foreground="Yellow"
Width="600"
FontSize="28"
Margin="10,0,0,0"
Height="65">
</TextBlock>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>

how to use progress bar in wpf popup control?

I am using C# and WPF for my GUI. My goal is to display a progress bar under the wpf popup control.
I am using below code add a progress bar under the popup control.
<Popup HorizontalAlignment="Left" Margin="338,261,0,0" Name="popup1" VerticalAlignment="Top" Height="38" Width="153" >
<StackPanel Background="Red">
<ProgressBar Height="15" HorizontalAlignment="Left" Margin="349,272,0,0" Name="progressBar1" VerticalAlignment="Top" Width="130" Foreground="#FF3EA3EA" Value="{Binding ElementName=textBox1, Path=Text.Length, Mode=OneTime}" Maximum="140" />
</StackPanel>
</Popup>
Please Help me.
Thanx in advanced!
You should use below code for showing ProgressBar under the Popup control:
<Popup Name="popup1" HorizontalAlignment="Left" Margin="338,261,0,0" AllowsTransparency="True" VerticalAlignment="Top" Height="38" Width="153">
<Grid>
<ProgressBar HorizontalAlignment="Left"
Name="progressBar1" Height="25"
VerticalAlignment="Center" Width="130"
Foreground="#FF3EA3EA"
Value="{Binding ElementName=textBox1, Path=Text.Length, Mode=OneTime}"
Maximum="140" ForceCursor="False" />
</Grid>
</Popup>

How to get specific element out of many elements in data template in Windows Phone 7

my listbox:
<ListBox x:Name="listBox" Grid.Row="2" FontSize="26" SelectionChanged="listBox_SelectionChanged" ItemsSource="{Binding SelectedSubGenre.PhotoCollection}">
<ListBox.ItemTemplate>
<DataTemplate>
<Border BorderBrush="BurlyWood" BorderThickness="1,1,1,1" Margin="0,0,12,24">
<StackPanel Orientation="Vertical" HorizontalAlignment="Left">
<StackPanel Orientation="Horizontal" HorizontalAlignment="Left">
<Image Source="{Binding Path}" Height="200" HorizontalAlignment="Left" Width="200" Margin="12,12,12,12"/>
<Button Foreground="yellow" Click="Button_Click" Height="150" Width="150" Content="add"/>
</StackPanel>
<TextBlock Text="{Binding Name}" Margin="12,0,0,0"/>
</StackPanel>
</Border>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
When the button is clicked I want to do something with the neighboring image of the button, how can I specify this particular image in my code? How can I get the neighboring image based on different buttons clicks
In the button click callback, do the following:
var btn = sender as Button;
var dc = btn.DataContext as YourDataObject;
dc.Path = "/path/to/new/image.jpg";
You might have to use a value converter to change the path from a string into a BitmapImage.

Preloader/Progress Bar in ListBox WP7

I would like to add a preloader to a ListBox, I already added a preloader to the whole pivot control, but I only show it for one listbox (I have a listbox for each pivot page) I wish to create separate preloaders for each listbox, has any one done this?
I currently have a preloader control, showing the loading text and progress bar
Is there any way I can attach a progress bar to the listbox, and show it until the data is loaded from the webservice (For each different listbox)?
This is my current preloader:
code preview of my list in xaml
<telerikPrimitives:RadDataBoundListBox HorizontalAlignment="Left" Margin="4,0,0,0" Name="listNearbyBusinesses" IsAsyncBalanceEnabled="True" AsyncBalanceMode="FillViewportFirst" SelectionChanged="listNearbyBusinesses_SelectionChanged" Height="535" VerticalAlignment="Top" Grid.RowSpan="2" Grid.ColumnSpan="2">
<telerikPrimitives:RadDataBoundListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<Image Width="100" Height="100" x:Name="m_Image" Source="{Binding Image}"/>
<StackPanel>
<TextBlock Text="{Binding Name}" TextWrapping="Wrap" Style="{StaticResource PhoneTextExtraLargeStyle}" />
<TextBlock Text="{Binding Type}" TextWrapping="Wrap" Margin="12,-6,12,0" Style="{StaticResource PhoneTextSubtleStyle}" />
<telerikInput:RadRating IsReadOnly="True" Value="{Binding Rating}" Margin="12" ItemShapeHeight="20" ItemShapeWidth="20" />
</StackPanel>
</StackPanel>
</DataTemplate>
</telerikPrimitives:RadDataBoundListBox.ItemTemplate>
</telerikPrimitives:RadDataBoundListBox>

Resources