silverlight-2.0

C# testing — why does ExpectedException tagged method pass when exception not thrown?

回眸只為那壹抹淺笑 提交于 2019-12-24 10:56:14
问题 In the past I have tested for expected exceptions like this: [TestMethod] public void TestThrowsException() { try { Foo(); Assert.Fail(); } catch (MyException ex){//good } } However I notice that there is a (cleaner?) way to test this using the ExpectedException attribute. Why does this test method pass when the exception is not thrown? Surely this defeats the purpose of the attribute. [TestMethod] [ExpectedException(typeof(MyException))] public void TestThrowsException() { } [Edit] I am

Pass 2 parameters to Silverlight control from SharePoint web part project into Silverlight application

心不动则不痛 提交于 2019-12-24 10:38:35
问题 I have 2 parameters defined in SharePoint web part project, meant to be passed into Application_Startup() in a Silverlight application when a user selects from 2 combo boxes (browsable properties). Somehow the Silverlight control does not render when i load it on the SharePoint site. With 1 parameter passed in, the control displays without error. Any ideas? Syntax? Examples? App.xaml.cs: private void Application_Startup(object sender, StartupEventArgs e) { //testing string _setArticles = null

Controlling rendering order (ZOrder) in Silverlight without using the Canvas control

我的梦境 提交于 2019-12-23 09:27:53
问题 I'm programmatically adding a UserControl to another in Silverlight 2 by adding it to the parent control's "Children" collection. At first this works fine. If I do something else to the window (in my case I'm scrolling the entire panel out of view then back into view) then it apparently changes the render order and causes my control to be behind the others. I'm searching for a way to control this behavior, to force my window to be on top. The Canvas control has a ZOrder property that allows

Setting initial control focus in Silverlight

核能气质少年 提交于 2019-12-22 04:25:13
问题 I'm looking for a way to automatically set the initial focus on a Silverlight UserControl to a specific control. I have a login page with a user name textbox and I'd like to have it so that as soon as the user goes to the page their cursor is already positioned and waiting in the username textbox instead of having to make them click the box. I tried calling .Focus in the UserControl's Loaded event but with no success. Anyone know how to do this? 回答1: I whipped up a quick SL3 app and it is

Silverlight - Getting the Domain Information

眉间皱痕 提交于 2019-12-20 03:52:29
问题 How does a Silverlight application ask the browser what domain its being served up from? UPDATE: Make sure if your class doesn't already have this using statement add it at the top your class. This will help you on some of the examples you'll see online. It confused me for a bit. using System.Windows.Browser; 回答1: How about HtmlDocument.DocumentUri? That'd get you what you need. Page about browser interop here . 回答2: As jcollum says you access the HtmlDocument.DocumentUri property to get lots

Access parent datacontext in listbox in Silverlight

倾然丶 夕夏残阳落幕 提交于 2019-12-17 22:15:55
问题 In Silverlight 2 I'm using a usercontrol which inherits the datacontext of the page that it's embedded on. This datacontext contains question text, a question type and a collection of answers. In the user control is a listbox which is bound to the collection of answers. As shown below: <ListBox DataContext="{Binding}" x:Name="AnswerListBox" ItemContainerStyle="{StaticResource QuestionStyle}" Grid.Row="1" Width="Auto" Grid.Column="2" ItemsSource="{Binding Path=AnswerList}" BorderBrush="{x:Null

Can Silverlight initiate Page Refreshes?

蹲街弑〆低调 提交于 2019-12-17 16:16:54
问题 UPDATE: An alternative title for this could be: How do I call javascript from my silverlight 2.0 application. Here is a quick question for all you Silverlight gurus. I have a Silverlight app that displays a stopwatch countdown. The app is hosted in an ASP.Net web application, What I want it to do is when the stopwatch hits zero, the app forces a server page refresh of the hosting page. Is this possible? If so, any chance of a code snippet? 回答1: Apparently you can call a JS script from

Silverlight and VS 2005 or VS 2008 Express Edition

╄→гoц情女王★ 提交于 2019-12-13 20:49:55
问题 Is is possible to create silverlight content in C# using Visual Studio 2005 Professional or Visual Studio 2008 Express Edition? I can't find an answer on Microsoft's web site. Thanks for any help! 回答1: Yes if the express edition is Visual Web Developer 2008 Express Edition. Here is a quote from this blog post from the guy who runs the development team for Silverlight at Microsoft: Developers can use either VS 2008 or the free Visual Web Developer 2008 Express to open and edit Silverlight 2

Enable button on another .xaml page

纵饮孤独 提交于 2019-12-13 03:55:32
问题 I have a button 'ReadMore' defined Page.xaml . How may I enable it again when I click on a button that closes ThumbnailDetails.xaml ? Users select an item @ a ListBox and they are directed to ThumbnailDetails.xaml by the way. Somehow it's not working? Page.xaml.cs: void NewsList_SelectionChanged(object sender, SelectionChangedEventArgs e) { StaffNews news = (StaffNews) NewsList.SelectedItem; if (news != null) { DetailsView.DataContext = news; DetailsView.Visibility = Visibility.Visible; /

display multiple data horizontally

半腔热情 提交于 2019-12-12 06:39:17
问题 how to display data horizontally in a list box. I had used the properties for reading data from the text box and i have to display these multiple data in to a list box (in one line, horizontally) . my code is shown below.. private void SaveButton_Click(object sender, RoutedEventArgs e) { LoadData(); } private void LoadData() { List<ItemList> MyList = new List<ItemList>(); MyList.Add(new ItemList { Subject = subjectText.Text }); MyList.Add(new ItemList { Createdtext = CreatedText.Text });