silverlight-4.0

Playing a sound in Silverlight with MediaElement and Caliburn Micro

谁说胖子不能爱 提交于 2019-12-06 08:12:51
问题 How can I play an MP3 in Silverlight using Caliburn Micro? The MediaElement's "play()" method needs to be executed based on a boolean variable in the ViewModel. Thanks in advance! 回答1: Use an IResult. sample code Edit: based on a Boolean value, if you describe the scenario of this I can alter the sample. View: <Grid> <MediaElement AutoPlay="False" Source="../Assests/Kalimba.mp3"></MediaElement> <Button x:Name="Play" Content="Play" Height="50" Width="150" /> </Grid> ViewModel: public class

Caliburn.Micro: Recovering from Exception in IResult

我只是一个虾纸丫 提交于 2019-12-06 07:55:06
This was posted at Caliburn.Micro discussions also. I'm really looking for advice and opinions on the best way to solve. Say I have the following Action public IEnumerable<IResult> SaveStation() { yield return Busy.MakeBusy(); yield return new StationSave(_station); yield return Busy.MakeNotBusy(); yield return Show.Tab<StationBrowseViewModel>(); } StationSave is an IResult wrapper around a simple (WCF) service invocation. The service uses FaultContract/FaultException for failures. In the case of a fault, the user needs to be notified and the FaultContract will contain some useful info about

Silverlight MVVM: where did my (object sender, RoutedEventArgs e) go?

[亡魂溺海] 提交于 2019-12-06 06:12:31
I am using commanding in my viewmodel to handle events. like for example I am handling a button click event like this: XAML <i:Interaction.Triggers> <i:EventTrigger EventName="Click"> <i:InvokeCommandAction Command="{Binding mvvmButtonclick}" /> </i:EventTrigger> </i:Interaction.Triggers> Viewmodel Code public ICommand mvvmButtonclick { get; private set; } Viewmodel Constructor code to wireup the command this.mvvmButtonclick = new ActionCommand(this.ButtonClickedEvent); Actual method in the viewmodel that gets called on button click private void ButtonClickedEvent() { MessageBox.Show("worked!!

Silverlight 4, subclassing WebClient

天大地大妈咪最大 提交于 2019-12-06 05:51:26
问题 Following an advice, I saw at several web pages (for example Using CookieContainer with WebClient class), I subclassed WebClient class to use a cookie with it: public class MyWebClient : System.Net.WebClient { } Now, when I initialize MyWebClient: MyWebClient wc = new MyWebClient(); it throws TypeLoadException. My OS is Windows 7 (japanese), so error message is not in english; I see it is related to security rules. What might be the problem? 回答1: WebClient's constructor is marked with the

Silverlight 4 Assembly Sharing Problem

南笙酒味 提交于 2019-12-06 05:48:56
问题 I have a WPF .NET 4.0 class library referencing a Silverlight 4 class library. The SL library compiles fine but when I compile the WPF class library, I get: Error 2 Unknown build error, 'Cannot resolve dependency to assembly 'System.Windows, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e' because it has not been preloaded. When using the ReflectionOnly APIs, dependent assemblies must be pre-loaded or loaded on demand through the ReflectionOnlyAssemblyResolve event.' MyProj

How can I combine some UserControls in SilverLight?

吃可爱长大的小学妹 提交于 2019-12-06 04:32:27
Maybe it is a simple question, but I can’t find the answer. I have three User controls that are different only with colour. There is code one of them: <UserControl x:Class="SilverlightApplication14.NodePicture" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:SilverlightApplication14"> <UserControl.Resources> <local:NodeViewModel x:Key="Children" /> </UserControl.Resources> <Grid x:Name="LayoutRootNodePicture" Height="100" Width="100" HorizontalAlignment="Center" DataContext="{Binding Source=

Error building Visual Studio 2010 Silverlight 4 projects on Windows 7 with XP Mode

末鹿安然 提交于 2019-12-06 04:14:26
I installed Visual Studio 2010 Beta 2 in an XP Mode VM on Windows 7. Then I created a trivial Silverlight 4 (beta) project and tried to build it. I get the following error: Error 1 The "ValidateXaml" task failed unexpectedly. System.IO.FileLoadException: Could not load file or assembly 'file://\tsclient\d\Users\me\Documents\Visual Studio 2010\Projects\SilverlightApplication2\SilverlightApplication2\obj\Debug\SilverlightApplication2.dll' or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515) File name: 'file://\tsclient\d\Users\me\Documents\Visual Studio

Is there a workaround for this tabcontrol/tabitem bug

╄→尐↘猪︶ㄣ 提交于 2019-12-06 03:42:46
Unless I'm mistaken (which I hope I am) there is a bug with the TabControl related to the visibility of TabItems . Here's XAML that reproduces the bug. <UserControl x:Class="TabControl_bug.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk" mc:Ignorable="d" d:DesignHeight="300" d:DesignWidth="400"> <Grid x:Name=

How to properly organize XAML resources in Silverlight?

天大地大妈咪最大 提交于 2019-12-06 03:41:50
I'm having some issues with resource files in my modular application. I have Infrastructure.DLL and some custom controls inside this DLL. Those controls using templates from themes/generic.xaml Issue that I have - Blend doesn't recognize those resources. Visual studio does. Ideally I'd like to have styles for my cusom controls inside generic.xaml and styles for other controls somewhere else in common library that I can reference from my modules. I also need Expression Blend and VS to work properly. How do I arrange solution to make it happen? PS. Important! WPF is different but I'm interested

Polling Pattern for Silverlight 4 WCF Ria Services

非 Y 不嫁゛ 提交于 2019-12-06 03:29:43
I am creating an application in Silverlight using Ria Services that can take quite a bit of time once the service call is initiated. I've looked for ways to increase the WCF service timeout, but the more I think it through, this is not the right aproach. What I would rather do is call the DomainContext and return right away, then have the client poll the server to find out when the long running query is complete. I'm looking for a pattern or example of a good way to implement something like this. One potential issue that keeps coming to mind are that web services should not keep state between