MapIcon visibility issue Windows Phone 8.1 Bing Maps - windows-phone-8.1

In WP8.1 project I created MapIcon and added it in MapElements. In some levels of zoom image is drawen but sometimes when I zoom in or zoom out it disappears (I thin when place names are to close to image). How is this possible to fix? Thanks in advance!
Code behind
mapIcon = new MapIcon();
mapIcon.NormalizedAnchorPoint = new Point(0.5, 1.0);
mapIcon.Image = RandomAccessStreamReference.CreateFromUri(new Uri("ms-appx:///Assets/mapIcon.png"));
mapIcon.Title = "You are here!";
MyMapControl.MapElements.Add(mapIcon);
mapIcon.Location = new Geopoint(new BasicGeoposition()
{
Latitude = geoLoc.Latitude,
Longitude = geoLoc.Longitude
});
XAML
<Grid Grid.Row="0" x:Name="ContentRoot" Margin="0,0,0,0">
<Maps:MapControl
x:Name="MyMapControl"
MapServiceToken="<my token>"
ZoomLevel="13.5"
LandmarksVisible="True"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
Margin="0,0,0,0"
>
</Maps:MapControl>
</Grid>

MapIcon elements are not guaranteed to be shown, they may be obscured by other elements, or if they are too close.
If you want to have a control that always shows, then use a XAML element: http://msdn.microsoft.com/en-us/library/windows/apps/xaml/dn792121.aspx#showing_xaml_controls_and_shapes_on_the_map

Related

How to change style code behind windows phone app 8.1 RT

I have a style in App.xaml like below
<Style TargetType="TextBlock" x:Key="Styletext">
<Setter Property="Fontsize" Value="13"/></Style>
And in the mainpage.xaml. I have
<TextBlock Content="ABC" Style={StaticResource Styletext/>
And 2 Button Aa-,Aa+ To Up size for that textblock. So Question is: How I can get Value from Property"Fontsize" and + or - it and Modify Style to Assign for TextBlock. Tks All
You can not change the style in static resource. For your requirement, you can considering setting the style of TextBlock in code behind.
For example:
var dynamicStyle = new Windows.UI.Xaml.Style();
var targetType = typeof(Windows.UI.Xaml.Controls.TextBlock);
dynamicStyle.TargetType = targetType;
dynamicStyle.Setters.Add(new Setter(Windows.UI.Xaml.Controls.TextBlock.FontSizeProperty, text01.FontSize + 1));
text01.Style = dynamicStyle;

Is there a way to use fontello ttf icons in Windows Phone 8?

I need to use ttf for some icons in my Win8 phone project. I did a research but couldn't find any resources. Is there a way to achieve this?
<TextBlock x:Name="textBlock" Text="\uE82E" FontFamily="/fontello.ttf#fontello" />
Custom Font Runtime
TextBlock t = new TextBlock();
FontFamily ff = new FontFamily("/Fonts/fontello.ttf#fontello");
t.FontFamily = ff;
t.Text = "&#xE821";
You can specify the Unicode value in this way:
XAML:
<TextBlock x:Name="textBlock" Text="" FontFamily="fontello.ttf#fontello" />
Code behind:
textBlock.FontFamily = new FontFamily("fontello.ttf#fontello");
textBlock.Text = "\uE82E";

Animate AppBarButtons like the E-mail application in Windows 8.1

The E-mail application in Windows 8.1 has a nice animation in the AppBar. When a button is not enabled the button disappears and the buttons that are left moves to fill empty space. This happens if several E-mails are selected in the application.
What should I do to add this in my application?
Edit: Below is the animation I’m talking about. The second button from the right is no longer available so it shrinks and then the other buttons is moved to the empty space.
The AppBar control uses StackPanel control for the grid in it. So when a button added, it automatically repositions all the other buttons. Well, even though I don't know how the E-Mail app does the animation you posted, I definitely can show you the way for it. Hope it does give an idea.
Here is the XAML of the AppBar:
<Page.BottomAppBar >
<AppBar IsSticky="True" Name="AppBar" IsOpen="True" FlowDirection="RightToLeft">
<StackPanel Name="bottomAppBar" Orientation="Horizontal" >
<AppBarButton Name="btnOptions" Icon="Setting" Width="100" Label="Options" />
<AppBarButton Name="btnHelp" Icon="Help" Width="100" Label="Help" />
<AppBarButton Name="btnExit" Icon="Import" Width="100" Label="Exit" />
</StackPanel>
</AppBar>
</Page.BottomAppBar>
Assuming you have a button that hides the button you don't want. Let's say btnHelp in this case.
The button should be like this:
<Button Content="Button" HorizontalAlignment="Left" Margin="170,79,0,0"
VerticalAlignment="Top" Height="66" Width="131" Click="Hide_Help_Click"/>
So the click event should be like this
private async void Hide_Help_Click(object sender, RoutedEventArgs e)
{
while (true)
{
await Task.Delay(1);
if( btn.Width > 0 )
{
btnHelp.Width = btnHelp.Width - 2;
}
else
{
break;
}
}
btnHelp.Visibility = Visibility.Collapsed;
}
This way, it's like the exit button goes out on top of the Help button, so maybe it's a little ugly, but this works like what you need. So a little change and maybe some animation you add, it should exactly do the same what you have posted.

Pivot Item Header Coulor Change opacity of all Headers Remains Same in windows Phone 8.1 Pivot Control

I am working on Pivot Control in Windows Phone 8.1 I Set foreground Property of pivotitem Header to Red Color it is working Fine but,I set all items header to Red Color and the Opacity of the Item Header Never Changes of UnFocused PivotItem cloud Please Help me how to solve this
Problem.
Here is the code
<Pivot Title="Pivot Title" >
<PivotItem >
<PivotItem.Header >
<TextBlock Text="One" Foreground="Red" FontSize="48"/>
</PivotItem.Header>
</PivotItem>
<PivotItem>
<PivotItem.Header>
<TextBlock Text="two" Foreground="Red" FontSize="48"/>
</PivotItem.Header>
</PivotItem>
<PivotItem>
<PivotItem.Header>
<TextBlock Text="three" Foreground="Red" FontSize="48"/>
</PivotItem.Header>
</PivotItem>
</Pivot>
The Default Styles Should be over ridden in Resource Dictionary <ResourceDictionary.ThemeDictionaries>
<ResourceDictionary x:Key="Default">
<SolidColorBrush x:Key="PivotHeaderForegroundUnselectedBrush" Color="#AFAFAF" />
<SolidColorBrush x:Key="PivotHeaderForegroundSelectedBrush" Color="#56C5FF" />
</ResourceDictionary>
</ResourceDictionary.ThemeDictionaries>
I guess you'll need to set a different VisualState for either the Selected or Unselected state.
Have a look over here How to Change Pivot Header Template in Windows Phone 8
Or you could use the SelectionChanged event handler for your pivot:
private void Pivot_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (e.AddedItems.Count > 0)
{
PivotItem currentItem = e.AddedItems[0] as PivotItem;
if (currentItem != null)
{
(currentItem.Header as TextBlock).Foreground = new SolidColorBrush(Colors.White);
}
}
if (e.RemovedItems.Count > 0)
{
PivotItem currentItem = e.RemovedItems[0] as PivotItem;
if (currentItem != null)
{
(currentItem.Header as TextBlock).Foreground = new SolidColorBrush(Colors.Red);
}
}
}
Hope it helps!

Disabling keyboard of windows phone having focus on Textbox

I am new in Windows Phone.
In my app I have a textbox where cursor will continuously blink for input at first. I have a custom dialpad to take input from users. So I have to disable the Windows Phone Keyboard.
After searching online, most of the solution is based on removing the focus from textbox to hide the keyboard.
In my case, its not happening since keyboard pops up and hide instantly.
Any help would be highly appreciated.
Another thing: I also need the cursor to be blinking in textbox.
May this will help you, create GotFocus event of your textbox.
GotFocus="input_GotFocus"
private void input_GotFocus(object sender, RoutedEventArgs e)
{
this.Focus();
}
One workaround could be to not use TextBox at all. Instead, you can use a simple TextBlock and on tap on the TextBlock, open your custom keypad. You can probably toggle visibility of the keypad to hide/unhide it. on key press of the keypad, update the text of the TextBlock.
EDIT : Adding a sample code for this (with cursor implementation as well)
Xaml for my custom TextBox implementation :
<Border x:Name="brdTextBox" Background="White" BorderBrush="Blue" HorizontalAlignment="Stretch" Height="100"
Margin="10">
<StackPanel Orientation="Horizontal">
<TextBlock x:Name="txtEnterText" FontSize="28" Foreground="Black" Margin="0"></TextBlock>
<TextBlock x:Name="txtCursor" FontSize="28" Foreground="Black" Text="|" Margin="0"></TextBlock>
</StackPanel>
</Border>
A sample code behind, that uses timer to control the tick of the cursor :
Timer timer = new Timer((obj) =>
{
Dispatcher pageDispatcher = obj as Dispatcher;
pageDispatcher.BeginInvoke(() =>
{
if (txtCursor.Text == "|")
{
txtCursor.Text = "";
}
else
{
txtCursor.Text = "|";
}
});
}, this.Dispatcher, 1000, 1000);
After this, you can probably bring up your keypad on border tap, and on key event of the keypad, fill up the textblock. You can tweak the timer duration and intervals to achieve a close resemblance to the actual cursor.
Hope it helps.