x:Type in Windows Phone App - windows-phone-7

In a WPF Application I can use x:Type, e.g. for ConverterParameter:
<TextBlock Text="{Binding SelectedParty.Firstname}" Visibility="{Binding SelectedParty,Converter={StaticResource TypeToVisibilityConverter}, ConverterParameter={x:Type model:PersonParty}}"/>
In a Windows Phone 8 App "x:Type" is unavailable! How can I pass a type?
Thanks!

You could just pass the object as the parameter and then determine it's type in the converter.
This would therefore mean you're creating a "PartyToVisibility" converter but just basing the logic on the type of the party.

Related

Is NativeScript Angular xml space sensitive

I have been trying out NativeScript Angular and started with the default Angular app on Windows using VSCode (that shouldn't matter). The default app has the following xml for the items component:
<GridLayout>
<ListView [items]="items">
<ng-template let-item="item">
<StackLayout>
<Label [nsRouterLink]="['/item', item.id]" [text]="item.name"></Label>
</StackLayout>
</ng-template>
</ListView>
</GridLayout>
Now if I add an additional space before the terminating GridLayout tag, i.e. on last line above, the app breaks up with following message:
An uncaught Exception occurred on "main" thread.
Calling js method run failed
Error: View not added to this instance. View: ProxyViewContainer(8) CurrentParent: Page(4) ExpectedParent: AppHostView(1)
I could not find any documentation where it is specified that the xml must be formatted. Is this expected behavior or is there something wrong with my setup?
As far as I know
</ListView>
</GridLayout>
this should work..!!
see if you can re-produce this error on playground and share here..

Unknown crashes happening for Invalid Cast Exception "TappedRoutedEventArgs" -> "FrameworkElement"

Specified cast is not valid.","stack_trace":"System InvalidCastException: Unable to cast object of type 'Windows UI Xaml Input TappedRoutedEventArgs' to type 'Windows UI Xaml FrameworkElement' at GalaSoft MvvmLight Command RelayCommand`1 Execute(Object parameter) at Microsoft Xaml Interactions Core InvokeCommandAction Execute(Object sender Object parameter) at Microsoft Xaml Interactivity Interaction ExecuteActions(Object sender ActionCollection actions Object parameter) at Microsoft Xaml Interactions Core EventTriggerBehavior OnEvent(Object sender Object eventArgs
I have been getting a lot of this exception for my Windows Phone Store App from the store crash report.But not able to figure out the issue.Please help.

Data binding the Image control in Windows 8 to a URL?

In Windows 8/Store programming, how would you go about databinding an image to a URL. In other platforms I've worked with, I would set the source property (or equivalent) to the URL and the platform would handle it for me, but that doesn't seem to be the case here.
I'm currently binding it to a property for my business object that is of type "string", and returns the URL of the image that I want populated in the image control. How would I go about doing this?
Turns out this is really easy.
Code:
<Image Stretch="UniformToFill">
<Image.Source>
<BitmapImage UriSource="{Binding Path=ImageUrl}" />
</Image.Source>
</Image>
ImageUrl is a Uri containing the path to the remote image.

How can I get MP3 flux with Windows Phone 7?

I tried this code, but it didn't work:
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<MediaElement Height="120"
HorizontalAlignment="Left"
Margin="-12,148,0,0"
Name="mediaPlayer"
VerticalAlignment="Top"
Width="474"
AutoPlay="True"
/>
</Grid>
C#:
Uri Path = new Uri("http://streaming.acc.net:8000/kalilo");
mediaPlayer.Source = Path;
Looks like you're using a unsupported type of stream. And since your link isn't valid, that's all the info we can provide.
Remember that you can't play music in the emulator, and on the device you need to use WPConnect.exe to connect instead of Zune, to make it actually play.
If that is a streaming service, MediaElement is a basic, but often unreliable source because of possible interruptions (e.g. switching from WiFi to a cell data connection). It works in most situations, but it has restrictions on media content that is passed through it.
Assuming that the URI you are showing belongs to a Shoutcast stream, it is not supported by default and you need to implement a connector through MediaStreamSource, even if you receive MP3 bytes.
Here is a great MediaStreamSource example from Tim Heuer.
Also worth checking out - ManagedMediaHelpers.

whindow phone IE-7 java script prb

I have made a webpage. The IE 7 of windows 7 doesn't execute Javascript. How do I enable Javascript on the Windows Phone?
Windows Phone 7 runs a mobile version of IE9 so there should be no problems executing javascript. The only thing I can think of with the little information is that you are trying to use a webbrowsercontrol from within an application. In that case you should set the IsScriptEnabled property to true to enable scripts within the control.
chirag !
In window phone 7, you can enable Javascript.
in xaml , you can set isScriptEnabled= true.
Examle:
<phone:WebBrowser HorizontalAlignment="Left" Width="480" HorizontalContentAlignment="Left" VerticalContentAlignment="Top" ScrollViewer.VerticalScrollBarVisibility="Visible" Name="webBrowser" Height="80" VerticalAlignment="Bottom" IsScriptEnabled="True" ScriptNotify="webBrowser_ScriptNotify" Navigated="webBrowser_Navigated" Navigating="webBrowser_Navigating" />
you can use event :
private void webBrowser_ScriptNotify(object sender, Microsoft.Phone.Controls.NotifyEventArgs e)
{
//your code : e is returned from the javascript code if javaScript is active
}
You can down load HTML content by use : webClient or string htmlcontent = webBrowser.SaveToString
Hope this help ! Thongaduka

Resources