Friday, February 1, 2013

Telerik Silverlight PadPane Z-Order issue in RadDocking control

Telerik Silverlight PadPane Z-Order issue in RadDocking control

I have created a usercontrol that contains a RadDocking control, with several panes, but they seem to lose their "z-order" when panes are closed.

For example, if I add 3 panes (pane1,pane2,pane3) to a panegroup in the following order: pane1, pane2, pane3.

I close pane 3, and pane 1 becomes the active pane instead of pane 2 - it is as if it goes back to the 1st item in the pane group

Any ideas?

Here is the XAML:

<telerik:RadDocking>     <telerik:RadDocking.DocumentHost>             <telerik:RadSplitContainer>                 <telerik:RadPaneGroup>                     <telerik:RadPane x:Name="pane1" Title="pane1">             <TextBlock Text = "pane1" />             </telerik:RadPane>                      <telerik:RadDocumentPane x:Name="pane1" Title="pane2">             <TextBlock Text = "pane2" />             </telerik:RadDocumentPane>                       <telerik:RadPane x:Name="pane3" Title="pane3">             <TextBlock Text = "pane3" />             </telerik:RadPane>         </telerik:RadPaneGroup>             <telerik:RadSplitContainer>  <telerik:RadDocking.DocumentHost> </telerik:RadDocking> 

Answers & Comments...

Answer: 1

I heard back from Telerik:

this is a know issue that was fixed in our Q3 2012 SP1 release of RadControls. All you need to do is download that release or any internal build after it.

by : Rick Hodderhttp://stackoverflow.com/users/349994




Assigning x:Name to Thickness throws exception

Assigning x:Name to Thickness throws exception

Can anyone explain why this throws an exception?

<UserControl>     <Grid>         <Grid.Margin>             <Thickness x:Name="thickness" />         </Grid.Margin>     </Grid> </UserControl> 

If I remove the x:Name attribute, then it runs successfully.

Error details:

Message: Unhandled Error in Silverlight Application Code: 4004
Category: ManagedRuntimeError
Message: System.NullReferenceException: Object reference not set to an instance of an object. at SilverlightBindingTest.MainPage.InitializeComponent() at SilverlightBindingTest.MainPage..ctor() at SilverlightBindingTest.App.Application_Startup(Object sender, StartupEventArgs e) at MS.Internal.CoreInvokeHandler.InvokeEventHandler(UInt32 typeIndex, Delegate handlerDelegate, Object sender, Object args) at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, Int32 actualArgsTypeIndex, String eventName, UInt32 flags)

Answers & Comments...

Answer: 1

The Name attribute is a DependencyObject and as such can only be set on another DependencyObject.

Thickness is not a DependencyObject, so you cannot use the Name attribute.

by : TriggerPinhttp://stackoverflow.com/users/1549726




Create gridview with variable number of columns

Create gridview with variable number of columns

I have to generate a gridview with the numbers of columns depending on a period of time then bind around 10 rows of data to the grid

Sometimes, I'll need to see every day in a year -> 365 columns

or every day in a month -> 30,31 columns

or every hour in a week -> 168 columns

or sometimes from the 15th of january to the 23 of march where I'll have to count the number of days.

My idea was to create as many object types as necessary to handle each possible case and I would call the correct type when asked.

However this seems cumbersome since creating an object with 365 properties then one with 168, etc... doesn't seems optimized.

How should I implement that ?

Answers & Comments...

Answer: 1

Generating the columns should be easy enough. Creating classes can be done dynamically at runtime using the ICustomTypeProvider interface.

Essentially, you can create a dynamic type with whatever properties you want. Unlike generating Types with IL, you can also dynamically add properties whenever you like.

by : TriggerPinhttp://stackoverflow.com/users/1549726




Silverlight DataBinding Error

Silverlight DataBinding Error

I've a GridView which has RowDetail. I want to each time user clicks on the rows get some detail from database, I use Telerik GridView. In normal way it's not possible or at least I don't know how, because RowDetail context binded directly to the grid DataContext, what I want is more than what GridRow contains it. What I found is maybe I can set RowDetailTemplate DataContext to UserControl by naming the UserControl so I can reference RowDetail to other model. My code is something like this

    <UserControl     x:Name="mainPageView"     x:Class="Project.Client.TestView"     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:telerik="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.GridView"      mc:Ignorable="d"     d:DesignHeight="300" d:DesignWidth="400">      <UserControl.Resources>         <DataTemplate x:Key="ContactRowDetailTemplate" >             <Grid Background="Transparent"                 DataContext="{Binding DataContext.ContactStatModel,                  ElementName=mainPageView,Mode=OneTime}">                 <Grid.RowDefinitions>                     <RowDefinition Height="28" />                 </Grid.RowDefinitions>                 <Grid.ColumnDefinitions>                     <ColumnDefinition Width="Auto" />                     <ColumnDefinition Width="Auto" />                     <ColumnDefinition Width="Auto" />                 </Grid.ColumnDefinitions>                 <TextBlock Text="Sent SMS Count" Grid.Column="0" Grid.Row="0" />                 <TextBlock Text=":" Grid.Column="1" Grid.Row="0" />                 <TextBlock Text="{Binding SMSCount}" Grid.Column="2" Grid.Row="0" />              </Grid>         </DataTemplate>     </UserControl.Resources>      <telerik:RadGridView           x:Name="gridView"         AutoGenerateColumns="False" Height="Auto" Grid.Row="3"         ItemsSource="{Binding VOutboxList, Mode=TwoWay}"         SelectedItem="{Binding VOutboxModel, Mode=TwoWay}"         RowDetailsTemplate="{StaticResource ContactRowDetailTemplate}"         LoadingRowDetails="gridView_LoadingRowDetails">         <telerik:RadGridView.Columns>             <telerik:GridViewDataColumn UniqueName="FirstName"  Header="First Name" Width="150" />             <telerik:GridViewDataColumn UniqueName="LastName" Header="Last Name" Width="150" />         </telerik:RadGridView.Columns>     </telerik:RadGridView>  </UserControl> 

But this time I get this exception

{Error: System.Exception: BindingExpression_CannotFindElementName} 

Any advice will be helpful. Best Regards.

Answers & Comments...

Answer: 1

The reason for this is that WPF's and Silverlights DataGrid columns live outside the logical tree and thus make it impossible to use a binding source specified using ElementName which is common when referencing ViewModel properties such as commands from within DataGrid Template Columns. For more information about this problem see: http://blogs.msdn.com/b/jaimer/archive/2008/11/22/forwarding-the-datagrid-s-datacontext-to-its-columns.aspx

The class below act's as glue between the column and the world around it. It was written for Silverlight's built-in DataGrid but should be easy enough to adapt it for the Telerik Grid. It can be used like this:

<DataTemplate x:Key="ContactRowDetailTemplate" >   <Grid Background="Transparent"     DataContext="{Binding ParentDataGrid.DataContext.ContactStatModel,      ElementName=shim,Mode=OneTime}">         <Shims:DataGridShim x:Name="shim"/>     <Grid.RowDefinitions>       <RowDefinition Height="28" />     </Grid.RowDefinitions>     <Grid.ColumnDefinitions>       <ColumnDefinition Width="Auto" />       <ColumnDefinition Width="Auto" />       <ColumnDefinition Width="Auto" />     </Grid.ColumnDefinitions>     <TextBlock Text="Sent SMS Count" Grid.Column="0" Grid.Row="0" />     <TextBlock Text=":" Grid.Column="1" Grid.Row="0" />     <TextBlock Text="{Binding SMSCount}" Grid.Column="2" Grid.Row="0" />   </Grid> </DataTemplate>  public class DataGridShim : FrameworkElement {   /// <summary>   /// Initializes a new instance of the <see cref="DataGridShim"/> class.   /// prepares the ParentDataGrid property for consumption by sibling elements in the DataTemplate   /// </summary>   public DataGridShim()   {     Loaded += (s, re) =>     {       ParentDataGrid = GetContainingDataGrid(this);     };   }    /// <summary>   /// Gets or sets the parent data grid.   /// </summary>   /// <value>   /// The parent data grid.   /// </value>   public DataGrid ParentDataGrid { get; protected set; }    /// <summary>   /// Walks the Visual Tree until the DataGrid parent is found and returns it   /// </summary>   /// <param name="value">The value.</param>   /// <returns>The containing datagrid</returns>   private static DataGrid GetContainingDataGrid(DependencyObject value)   {     if (value != null)     {       DependencyObject parent = VisualTreeHelper.GetParent(value);       if (parent != null)       {         var grid = parent as DataGrid;         if (grid != null)           return grid;          return GetContainingDataGrid(parent);       }        return null;     }      return null;   } } 
by : Oliver Weichholdhttp://stackoverflow.com/users/88513

Answer: 2

I've even simplified the accepted solution. It uses the trick that from DataTemplates, you can reference static resources. And in static resources, you can use ElementName in binding.

  1. Create a new control:

    public class ElementProxy : DependencyObject {     public DependencyObject Element     {         get { return (DependencyObject)GetValue(ElementProperty); }         set { SetValue(ElementProperty, value); }     }  public static readonly DependencyProperty ElementProperty =     DependencyProperty.Register("Element", typeof(DependencyObject), typeof(ElementProxy), new PropertyMetadata(null)); } 
  2. Put it into static resources of the DataGrid or its parent control and reference it through StaticResource:

    <UserControl.Resources>     <helpers:ElementProxy Element={Binding ElementName=mainPageView} x:Key="Proxy" /> </UserControl.Resources> 

(in column template:)

    <DataTemplate>         <Grid DataContext={Binding Element.DataContext,Source={StaticResource Proxy}} />     </DataTemplate> 
by : giushttp://stackoverflow.com/users/19712




Common approach to cancel different asynchronous operations

Common approach to cancel different asynchronous operations

I have somewhat non-trivial task and I'd appreciate to hear from you, how to solve it better. In a nutshell, this is about managing long-running tasks of different nature. While I'm doing this for Windows Phone, I feel like some general principles could be applied here, based on C# and .NET standard approaches.

My application is mainly built around different service classes, which handles data from the cloud, GPS, commercial transactions, authentication, etc. All the services are owned by our team. Services are used inside view models, but API in different services is currently of different fashion. Somewhere it's async/await, somewhere it's event-based (like in positioning, where I need to update geo coordinate constantly).

Now I've started to look into the issue of application activation/deactivation, and I would like to handle this in a common way in all my view models. One of the main thing is cancellation of current async operations when app is closing or when user navigates to another page. I want to put the code related to that into something like BaseViewModel, to avoid code duplication. However this means that I need to handle cancellation in all view models uniformly.

Here comes the challenge. For example, async/await stuff could be cancelled by CancellationToken. I could collect all the cancellation tokens in BaseViewModel, and use them all when needed. However, this will not work with event-based asynchrony. Of course one could delegate concrete cancellation operation to child view model, via virtual function call. But I want to move as much as possible code to the BaseViewModel.

So, is there a way to unify cancellation of Tasks and event-based asynchrony?

Answers & Comments...

Answer: 1

The event-based pattern is somewhat non-uniform, so I don't see that a completely clean solution will exist without writing some case-by-case code for each operation. Some options could be:

  • Wrap up your non-task based async operations in tasks to provide a uniform approach. Requires quite a bit of boring code (due to the non-uniformity of the EAP).

  • Wrap up both your task and event subscriptions in a simple cancellation delegate, and have your base class just know about these cancellation actions instead (maybe a bit more than just an action, but something relatively simple)

It seems to me that anyway you will need to write per-event code for cancellation, but with the use of a couple of helper methods for storing the info for the task and event based operations, it might be quite lightweight.

by : Nicholas Whttp://stackoverflow.com/users/513410

Answer: 2

Why wouldn't the CancellationToken(Source) infrastructure work for event-driven components? You can register a callback with the token that is called when cancellation occurs. In that callback you can unsubscribe from event sources. Speaking in general terms you can perform any action necessary to quiescence the system. It is just a matter of distributing the token to all components concerned with cancellation.

Actually, this is the "beauty" of the CancellationToken(Source) infrastructure. It is so simple yet so generally applicable.

by : usrhttp://stackoverflow.com/users/122718




how to apply Transition animation between two Datatemplates while swapping within same WPF Listbox?

how to apply Transition animation between two Datatemplates while swapping within same WPF Listbox?

I have a scenario where i have two different DataTemplates for a Listbox which i apply dynamically as needed while changing the ItemsSource of Listbox. The two DataTemplates containing different UI, all works fine i am able to swap between both Datatemplates.

My concern is the while swapping between the templates i want to add animation to give a feeling of change in UI, but right now it happens in one click its just applies other template at once which does not give a feeling of change in UI Transition.

So what i want to do whenever a different DataTemplate is applied to Listbox i want to apply transition animation which gives a feel of change in UI similar to what we do in Mobile application where when you select an item from Listbox it shows new list of items with a Transition effect.

I hope i am able to explain myself.

If anyone has done that short of work please help me how can i achieve the same transition effect while swapping two DataTemplates with each other.

Thank you

Answers & Comments...

Answer: 1

The Silverlight toolkit has a TransitioningContentControl that does exactly what you are after. I think the WPF toolkit has one too, but cant find it right now.

You might consider converting the SL control to WPF - should be easy enough. Or you could try this one from Codeproject instead

by : TriggerPinhttp://stackoverflow.com/users/1549726




open a silverlight window in a new tab

open a silverlight window in a new tab

i have a silverlight window, when a button pressed i want to open it on a new tab\window, how can i do it?

Answers & Comments...

Answer: 1

The HtmlPage.Window.Navigate() method has an overload which allows you to specify which frame to load the new page in. _blank is used for new window/tab.

HtmlPage.Window.Navigate(new Uri("http://google.com"), "_blank"); 
by : Charlie Somervillehttp://stackoverflow.com/users/47322

Answer: 2

You can use a HyperlinkButton for this.

<HyperlinkButton NavigateUri="http://www.silverlight.net" TargetName="_blank" Content="HyperlinkButton"/> 

When you specify "_blank" as TargetName. A new tab or window is opened and the specified uri gets opened. Also other values for TargetName are valid. See here more.

Edit:

To open the same Silverlight application in a new tab you can use the System.Windows.Browser.HtmlPage.Document.DocumentUri as NavigationUri of the HyperlinkButton.

by : Jehofhttp://stackoverflow.com/users/83039

Answer: 3

Taking your question literally the answer is:-

HtmlPage.Window.Navigate(HtmlPage.Document.DocumentUri, "_blank");  
by : AnthonyWJoneshttp://stackoverflow.com/users/17516

Answer: 4

The only thing you can open 'in a new tab' is a web page. If you want to open a different Silverlight application in a new tab, then it will need to be hosted in a webpage, and you will need to use HtmlPage.Window.Navigate() to open that page. You cannot just open a new tab and have it somehow contain something embedded in your application - that is not how webbrowsers work.

by : SmartyPhttp://stackoverflow.com/users/18005

Answer: 5

Also try this in .aspx Page

<head id="Head1" runat="server">     <title>Your Applicateion</title>     <script type="text/javascript">         var windowClose = window.close;         window.close = function () {             window.open("", "_self");             windowClose();         }         function OpenWindow() {             window.opener = 'x';             window.close();                         window.open('Default.html', '_blank', 'status=no,toolbar=no,location=no,menubar=no,directories=no,resizable=no,scrollbars=no,height=' + screen.availHeight + ',width=' + screen.availWidth + ',top=0,left=0');             return false;         }     </script> </head> <body onload="OpenWindow();">     <form id="form1" runat="server">     </form> </body> 
by : Manoj Savaliahttp://stackoverflow.com/users/780955

Answer: 6

Rather than using the URI like people here are suggesting you should just create an object of your page and pass it to the navigate method.

Dim yournewpage as new OrganiztrionInfoFromToolTip() HtmlPage.Window.Navigate(yournewpage, "_blank"); 
by : Zelxinhttp://stackoverflow.com/users/2030351




How can i show power view report on my web application?

How can i show power view report on my web application?

I want to show my powerview (.rdlx) reports on my web asp.net web page. I can't use an iframe because I do not have access to the Power View server. In my web application, i want to use powerview reports in my project.

How can i open powerview reports from asp.net web page?

Answers & Comments...




Silverlight Analytics Framework doesn't send traffic to Google Analytics

Silverlight Analytics Framework doesn't send traffic to Google Analytics

I've downloaded the latest sample code from the Silverlight Analytics Framework site and ran the SL5 version with an update value for my WebPropertyId. I can see the outbound traffic in Fiddler, but nothing ever shows up on Google Analytics site traffic charts.

I saw somewhere that the account should be setup as a website and not an app. I've tried both ways with no success.

Answers & Comments...




Formatting Telerik Chart and Legend Labels in Silverlight

Formatting Telerik Chart and Legend Labels in Silverlight

I am trying to format a column called 'Month' using the 3-character month abbreviation in my data grid which is bound to a bar chart. My grid and chart are based on this demo example: http://demos.telerik.com/silverlight/#Chart/Aggregates. Basically, the grid compiles data and summarizes by Year, Quarter, Month, and then some other categories as well. For the Month column, I tried two different methods (for sorting purposes, I have to use an integer or some date value for the month). First, I just made Month an integer field and then used a converter mapped in the xaml for the 'Month' field to display 'JAN', 'FEB', etc. This worked fine for the grid, but the chart would display 1, 2, etc. instead of the month abbreviation. I researched this and was not able to come up with a solution to map the converter to the chart. So, I tried making the Month field a datetime and then set the value to 1/1/1900, 2/1/1900, etc. and specified the format of the field to 'MMM' in the xaml for the grid. I then used the following statement to set the the format in the chart when the user grouped by month:

SalesAnalysisChart.DefaultView.ChartArea.AxisX.DefaultLabelFormat = "MMM";  

This partially worked in that when the months were displayed across the x-axis they were labeled properly, but not when they appeared in the legend (the user, of course, can group by any of the columns which may or may not include month). I've tried setting LegendItemLabelFormat, ItemLabelFormat, etc. but without success. I'm not sure of the element on which to set the property. I only need to change the default format for just the Month column - all other columns should display normally when grouped. I also came across a class called 'LegendItemFormatConverter' which looks promising but I can't find any examples as to how to implement it. I would actually prefer the converter method because the converter I wrote displays the month abbreviation in all caps, whereas the 'MMM' format displays in upper/lower case. Here is the converter code that I originally used for the grid:

using System;  using System.Net;  using System.Windows;  using System.Windows.Controls;  using System.Windows.Documents;  using System.Windows.Ink;  using System.Windows.Input;  using System.Windows.Media;  using System.Windows.Media.Animation;  using System.Windows.Shapes;  using System.Windows.Data;   namespace ApolloSL  {      public class MonthConverter : IValueConverter      {          public object Convert(object value, Type targetType, object parameter,     System.Globalization.CultureInfo culture)          {              if (value != null)              {                   DateTime date = new DateTime(1900, (Int32)value, 1);                  return date.ToString("MMM").ToUpper();              }              else             { return ""; }          }           public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)          {              return value.ToString();          }      }  }  

Please help...

Thanks in advance for your assistance,

Bryan

Answers & Comments...

Answer: 1

There is an answer in the Telerik forums.

by : Alanhttp://stackoverflow.com/users/475752




C# Execute Method every X Seconds Until a condition is met and then stop

C# Execute Method every X Seconds Until a condition is met and then stop

I'm using a Silverlight C# Button click event to pause 10 seconds after click then call a method every x seconds until a specific condition is met: Either x=y or elapsed seconds>=60 without freeziing the UI.

There are several different examples out there. I am new to C# and am trying to keep it simple. I came up with the following, but I don't have the initial 10 second wait which I need to understand where to put and it seems like I have an endless loop. Here is my code:

  public void StartTimer()     {          System.Windows.Threading.DispatcherTimer myDispatchTimer = new System.Windows.Threading.DispatcherTimer();          myDispatchTimer.Interval = TimeSpan.FromSeconds(10); // initial 10 second wait         myDispatchTimer.Tick += new EventHandler(Initial_Wait);         myDispatchTimer.Start();     }      void Initial_Wait(object o, EventArgs sender)     {         System.Windows.Threading.DispatcherTimer myDispatchTimer = new System.Windows.Threading.DispatcherTimer();         // Stop the timer, replace the tick handler, and restart with new interval.          myDispatchTimer.Stop();         myDispatchTimer.Tick -= new EventHandler(Initial_Wait);         myDispatchTimer.Interval = TimeSpan.FromSeconds(5); //every x seconds         myDispatchTimer.Tick += new EventHandler(Each_Tick);         myDispatchTimer.Start();     }       // Counter:     int i = 0;      // Ticker     void Each_Tick(object o, EventArgs sender)     {               GetMessageDeliveryStatus(messageID, messageKey);             textBlock1.Text = "Seconds: " + i++.ToString();       } 

Answers & Comments...

Answer: 1

Create a second event handler that changes the timer. Like this:

public void StartTimer() {     System.Windows.Threading.DispatcherTimer myDispatcherTimer = new System.Windows.Threading.DispatcherTimer();      myDispatchTimer.Interval = TimeSpan.FromSeconds(10); // initial 10 second wait     myDispatchTimer.Tick += new EventHandler(Initial_Wait);     myDispatchTimer.Start(); }  void Initial_Wait(object o, EventArgs sender) {     // Stop the timer, replace the tick handler, and restart with new interval.     myDispatchTimer.Stop();     myDispatchTimer.Tick -= new EventHandler(Initial_Wait);     myDispatcherTimer.Interval = TimeSpan.FromSeconds(interval); //every x seconds     myDispatcherTimer.Tick += new EventHandler(Each_Tick);     myDispatcherTimer.Start(); } 

The timer calls Initial_Wait the first time it ticks. That method stops the timer, redirects it to Each_Tick, and adjusts the interval. All subsequent ticks will go to Each_Tick.

If you want the timer to stop after 60 seconds, create a Stopwatch when you first start the timer, then check the Elapsed value with every tick. Like this:

Modify the InitialWait method to start the Stopwatch. You'll need a class-scope variable:

private Stopwatch _timerStopwatch;  void Initial_Wait(object o, EventArgs sender) {     // changing the timer here     // Now create the stopwatch     _timerStopwatch = Stopwatch.StartNew();     // and then start the timer     myDispatchTimer.Start(); } 

And in your Each_Tick handler, check the elapsed time:

if (_timerStopwatch.Elapsed.TotalSeconds >= 60) {     myDispatchTimer.Stop();     myDispatchTimer.Tick -= new EventHandler(Each_Tick);     return; } // otherwise do the regular stuff. 
by : Jim Mischelhttp://stackoverflow.com/users/56778




Poor anti aliasing of 3D model using XNA in Silverlight, how to fix?

Poor anti aliasing of 3D model using XNA in Silverlight, how to fix?

In Silverlight, I am embedding a 3D model using XNA. The model is rendered in a DrawingSurface control. The issue I am having is that the model render is quite poor in quality. The model has jagged edges even with anti aliasing turned on (see code below), and the model is also blurry.

Dim comp As New OffscreenCompositionMode     comp.PreferredMultiSampleCount = 4     comp.RenderTargetUsage = RenderTargetUsage.DiscardContents     comp.PreferredDepthStencilFormat = DepthFormat.Depth24      drawingSurfaceCtl.CompositionMode = comp 

I tried adjusting the multiSampleCount, camera position, lens and etc but to no effect. Does anyone have any suggestions on how to improve Anti Aliasing?

Also note that this is designed as an out of browser app on pc, and the xna game library cannot be used in this solution.

Thanks

Answers & Comments...




Accessing Telerik Silverlight RadGridView from Button on Group header

Accessing Telerik Silverlight RadGridView from Button on Group header

I have a RadGridView, that groups its contents. I have a Button on the group header When I click on the button (btnSave) I would like to get access to the group to read the group key.

What can I put in the Click of btnSave to accomplish this?

<telerik:RadGridView x:Name="grdNotams" Grid.Row="1" AutoGenerateColumns="False" RowIndicatorVisibility="Collapsed" ShowGroupPanel="False">     <telerik:RadGridView.Columns>         <telerik:GridViewDataColumn  UniqueName="colNewStatus" DataMemberBinding="{Binding NewStatus}" Header="New Status" IsFilterable="False" IsSortable="False">             <telerik:GridViewDataColumn.CellTemplate>                 <DataTemplate>                     <StackPanel Orientation="Horizontal">                         <telerik:RadRadioButton Content="C" Width="30" IsChecked="{Binding NewStatus, Mode=TwoWay, Converter={StaticResource StringToBooleanConverter},ConverterParameter=C}" GroupName="{Binding RadioButtonName}"/>                         <telerik:RadRadioButton Content="M" Width="30" Margin="5,0,0,0"  IsChecked="{Binding NewStatus, Mode=TwoWay, Converter={StaticResource StringToBooleanConverter},ConverterParameter=M}" GroupName="{Binding RadioButtonName}"/>                         <telerik:RadRadioButton Content="I" Width="30" Margin="5,0,0,0"  IsChecked="{Binding NewStatus, Mode=TwoWay, Converter={StaticResource StringToBooleanConverter},ConverterParameter=I}" GroupName="{Binding RadioButtonName}"/>                                                         </StackPanel>                 </DataTemplate>             </telerik:GridViewDataColumn.CellTemplate>         </telerik:GridViewDataColumn>         <telerik:GridViewDataColumn Header="Status" UniqueName="colStatus" DataMemberBinding="{Binding Model.Status, Converter={StaticResource StatusConverter}}" HeaderTextAlignment="Center" TextAlignment="Center" IsFilterable="False" IsSortable="False"/>         <telerik:GridViewDataColumn Header="Trip #" UniqueName="colTripNumber" DataMemberBinding="{Binding Model.TripNumber}" HeaderTextAlignment="Center" TextAlignment="Center" IsFilterable="False" IsSortable="False"/>         <telerik:GridViewDataColumn Header="Date" UniqueName="colDate" DataMemberBinding="{Binding Model.DepartureTime}" DataFormatString="d"  HeaderTextAlignment="Center" TextAlignment="Center" IsFilterable="False" IsSortable="False"/>     </telerik:RadGridView.Columns>     <telerik:RadGridView.GroupHeaderTemplate>         <DataTemplate>             <StackPanel Orientation="Horizontal">                 <telerik:RadButton x:Name="btnSave" Click="btnSave_Click">                     <StackPanel Orientation="Vertical">                         <Image Source="../images/save.jpg" Height="30" Width="30" HorizontalAlignment="Center"/>                         <TextBlock TextAlignment="Center" TextWrapping="Wrap">Update</TextBlock>                     </StackPanel>                 </telerik:RadButton>                 <TextBlock Text="{Binding Group.Key}" FontSize="14" FontWeight="Bold" FontStyle="{Binding EarliestNotamDepartureTime, Converter={StaticResource DateTimeToItalicsConverter}}" TextWrapping="Wrap" VerticalAlignment="Center" Padding="5"/>             </StackPanel>         </DataTemplate>     </telerik:RadGridView.GroupHeaderTemplate>     <telerik:RadGridView.GroupDescriptors>         <telerik:GroupDescriptor Member="NotamGroup"  >         </telerik:GroupDescriptor>         <telerik:GroupDescriptor Member="Model.NotamText">         </telerik:GroupDescriptor>     </telerik:RadGridView.GroupDescriptors> </telerik:RadGridView> 

Answers & Comments...




WCF response issue

WCF response issue

this is the service method implementation

I have come across some strange problem. I have a WCF service which exposes a method to save Observablcollection of user defined object. This object has a byte[] property and it also returns the same collection to client.

When I call this method the completed event doesn't get fired and if i again call the same method it starts executing the method repeatedly until wcf timed out.

Any guess what is going wrong there ?

Thanks.

Answers & Comments...

Answer: 1

How large is you collection? There are chances that this is happening due to sending huge data from server to client than max limit specified by HTTP response.

by : Neeleshhttp://stackoverflow.com/users/1254033

Answer: 2

I tried without returning Collection. I mean i commented the line result.Tag = collection and it is working fine.

I want to know Why it is behaving like this ?

I have a different method which returns the same collection and it is working fine. So why is returning of collection not working here ?

by : Gyandeephttp://stackoverflow.com/users/1748975




ASP.NET/ActiveX/Silverlight Screen Capture

ASP.NET/ActiveX/Silverlight Screen Capture

I need a way to capture the screen within a web application in any way possible. Is there such a way without installing other tools like SnagIt? Can I use Win32 DllImports within an ActiveX component and do it that way?

Thanks in advance!

Answers & Comments...

Answer: 1

On the Silverlight forums they say its not possible with just Silverlight, because of Security.

I think it should be possible somehow, because the PrintDocument is basically doing the same....
See below where we point to the LayoutRoot to print.

In the links from that forum they are registering a DLL in the GAC and using that one to create the screen shot. Not very nice ;-)
http://forums.silverlight.net/forums/p/163378/367809.aspx

private void ButtonPrint_Click(object sender, System.Windows.RoutedEventArgs e) {     PrintDocument pd = new PrintDocument();     pd.PrintPage += OnPrintPage;     pd.Print("from Silverlight"); }  private void OnPrintPage(object s, PrintPageEventArgs args) {     args.PageVisual = LayoutRoot; } 
by : Peter Gfaderhttp://stackoverflow.com/users/35693

Answer: 2

With pure Silverlight code, both in browser and out of browser, it's not possible to capture an image of the screen (thankfully! That would be a huge privacy and security issue if a rogue website could capture your screen and send it to their web site).

By writing a browser plug-in (such as an ActiveX control, which would work only in IE), you could write the necessary Win32 code to take a screen shot. It would still require some heavy lifting to manage the image, uploading, file security, etc. You might be able to write the COM control in C#, but it would need to be placed in the GAC (thus signed, etc.).

There are other solutions that involve local native installation and a browser based Silverlight application, but all require an installation on the PC.

I'd suggest considering instead a simple, zero-install (or click-once), EXE that can be run from a PC that just takes a screen shot and uploads it/e-mails/etc.. That would involve far fewer hacks to make it work.

Note that Windows 7 has a new accessory, called the Snipping Tool that can take an image of the screen and e-mail it.

by : WiredPrairiehttp://stackoverflow.com/users/95190

Answer: 3

Here is some code that will take a screen shoot of your silverlight app. and then you can send it or what ever :-)

Just create a silverlight project (with normal mainpage etc. and replace with this.

works in both 3.0 and 4.0 (havent tried 2.0 and lower)

Hope i helps Regards ReLoad

.CS

using System; using System.Collections.Generic; using System.Linq; using System.Net; using System.Windows; using System.Windows.Controls; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Animation; using System.Windows.Shapes; using System.Windows.Data; using System.Windows.Media.Imaging;

namespace SilverlightApplication1 { public partial class MainPage : UserControl { public MainPage() { InitializeComponent(); }

    private void UIelementShoot(object sender, 

RoutedEventArgs e) { theImageToSend.Source = new WriteableBitmap(elementToCapture, null); }

    private void ScreenShoot(object sender, 

RoutedEventArgs e) { theImageToSend.Source = new WriteableBitmap(LayoutRoot, null); }

    private void Button_Click(object sender, 

RoutedEventArgs e) {

    } } } 

XAML:

<UserControl     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:local="clr-namespace:SilverlightApplication1" x:Class="SilverlightApplication1.MainPage"     mc:Ignorable="d"     d:DesignHeight="300" d:DesignWidth="400">      <Grid x:Name="LayoutRoot" Background="White" Width="400" Height="300" >         <Image x:Name="theImageToSend" Margin="191,56,44,103" d:LayoutOverrides="HorizontalAlignment"/>         <TextBox x:Name="elementToCapture" Margin="37,56,0,130" TextWrapping="Wrap" Text="TextBox" Width="124" HorizontalAlignment="Left" d:LayoutOverrides="Width"/>         <Button Content="Make ScreenShoot" HorizontalAlignment="Right" Margin="0,0,44,26" VerticalAlignment="Bottom" Width="139" Click="ScreenShoot"/>         <Button Content="Make TextBox Shoot" HorizontalAlignment="Left" Margin="61,0,0,26" VerticalAlignment="Bottom" Width="139" Click="UIelementShoot"/>       </Grid> </UserControl> 
by : ReLoadhttp://stackoverflow.com/users/445135

Answer: 4

For anyone else that stumbles upon this in the future, there is also the grand option of using phantomjs (http://phantomjs.org/)!

by : Bennyhttp://stackoverflow.com/users/194261




TabBar in Windows Phone

TabBar in Windows Phone

I building my first Windows Phone App, and i saw something really nice on one of the apps, i add a screenshoot of this:

enter image description here

The description is: green - icons blue - textbox yellow - pages

And it is something like panorama , but here the icons(with the text) are in the top all the time, and, and press one of them the jump(with animation) to the chosen page, and of course if the user swipe on the page it move to the next page and the icons are get highlighted.

it's something like UITabBarController, and i want to know how i implement this control? it's some thing build in, if yes what is name? Or any good tutorial how to build it.

thanks!!

Answers & Comments...

Answer: 1

Looks like you need built-in control called Pivot

You can change Header template to put an icon in it:

 <controls:Pivot x:Name="pivot"                     Title="{Binding Name}"                   <controls:Pivot.HeaderTemplate>             <DataTemplate>                 <StackPannel>                     <Image Source="your icon path">                     <TextBlock Text="{Binding}" />                 </StackPannel>             </DataTemplate>         </controls:Pivot.HeaderTemplate> 
by : Anton Sizikovhttp://stackoverflow.com/users/555014




Silverlight TextBlock Binding to SelectedItem in ComboBox

Silverlight TextBlock Binding to SelectedItem in ComboBox

I have a ComboBox that is bound to a collection of CLR objects. Each item in the ComboBox is displayed via a DataTemplate. This DataTemplate contains an Image and a Title associated with the item. After a user clicks an item in the ComboBox, I want to display the selected items Title in another TextBlock in the screen.

My question is, how do I bind the Text property of the TextBlock to the Title property of the item selected in the comboBox?

Thank you!

Answers & Comments...

Answer: 1

Assuming you called the ComboBox "ComboBox1" You could use-

<TextBlock Text="{Binding ElementName=ComboBox1,Path=SelectedItem.Title}"/> 
by : Jason Quinnhttp://stackoverflow.com/users/337226




Silverlight LinqToSql SQL Tracing

Silverlight LinqToSql SQL Tracing

I am using Silverlight 5.0 with LinqToSQl and WCF RIA Services in my project. I am trying to figure out how to log Traces of the underlying SQL Statements (to Sql Server), either in debug mode, or log it to a console window, or file. I would need this for all CRUD operations.

All samples online point out to the DataContext.Log property, but I always find its value to be "Nothing", and also, I cannot get to it from the Client side of the project. If possible, I am planning to have a UserInterface to display the actual SQL Statements before proceeding to either retrieve or save data. This will be mainly for debugging purposes.

Is there a way to view the underlying SQL Statements from the client end (using a break point and checking the values in the Immediate window, or something like that)

Thanks.

Answers & Comments...

Answer: 1

If you want to log the sql statements executed by your DataContext you need to assign a TextWriter to the property Log of your DataContext.

Null is the default value of Log for the DataContext and therefore is logging of commands disabled.

To log the sql statements to the console, you can assign Console.Out to the property.

db.Log = Console.Out; 

If you want to write the log to a file you can assign a StreamWriter to the property.

by : Jehofhttp://stackoverflow.com/users/83039




Silverlight profiling

Silverlight profiling

I'd like to profile all silverlight applications that are running. To get started, I have to list all silverlight applications. I was suggested to use Fiddler library, which helps to analyse HTTP traffic, in order to discover whether a web page contains a silverlight application. This could be done with checking MIMEType attribute which indicates data type.

Is that a good idea? Any other suggestion?

Answers & Comments...




Object is not destructing after removing it from the collection

Object is not destructing after removing it from the collection

In Silverlight, I have a collection of tab items. On clicking of a button, I am adding a new tab with a control as content in the collection and showing it to the screen. Now, I have a "Close" button in the screen, calling which, the current visible tab removes from the collection and thus no longer visible in the screen.

I noticed that, though the tab item has been removed from the collection from the tab item and collection, the destructor of the control part of the tab is not getting call all the time. And sometime, it is getting called after a long time (not always).

Though the item has been removed, why it is taking time to call the destructor of the object? How can I resolve this issue? Any pointers?

Answers & Comments...

Answer: 1

The destructor of the object called by Garbage Collector, when it seems necessary. Programmer should not rely on the immediate calling the destructor.

by : Memoizerhttp://stackoverflow.com/users/1937750




How to set default datatype

How to set default datatype

I have an ItemsControl in which all the items except the type AType should have the same view. How could I do that?

I've tried object as DataType but it is forbidden (there is simplified example below):

<ItemsControl>     <ItemsControl.Resources>         <DataTemplate DataType="AType">                                                             <TextBox />                                                      </DataTemplate>         <DataTemplate DataType="System:Object">             <Border>                      <TextBlock Text="{Binding}" />                                                        </Border>         </DataTemplate>     </ItemsControl.Resources>                                     </ItemsControl> 

Answers & Comments...

Answer: 1

The best bet is to use a Template Selector, like this one

That way you can easily specify the template based on whatever condition you like.

by : TriggerPinhttp://stackoverflow.com/users/1549726




What can cause Ria Services 404 error, specifically the requests have '/binary' in them

What can cause Ria Services 404 error, specifically the requests have '/binary' in them

This is currently in development, Visual Studio 2012, Silverlight 5, and Ria Services. I've heard of these issues with deployment but i've not got that far yet.

When I look at the call in Fiddler the url looks like this:

http://127.0.0.1:81/ClientBin/DanielHarris-SilverlightApp-RiaService-NameOfDomainServiceClass.svc/binary/GetColours 

This is returning a 404, however I don't believe the '/binary' should be in the URL, and that if it was requesting via that then the call would succeed.

To give a bit more information here is an overview of the layout of the solution:

Class Library Containing an EF Entity Model (ObjectContext) Silverlight Application ASP.NET Web Application with a DomainService class ASP.NET Web Application with the actual website that display the silverlight XAP 
  • The ASP.NET App with the DomainService references the EntityModel class library
  • The Silverlight Application has RIA Services Enabled, the RIA services link in the SL Apps properties is set to the ASP.NET App with the DomainService class in it
  • The ASP.NET Web App with the actual website that displays the Silverlight XAP runs up and loads the control fine at the right point, any RIA calls fail

I am wondering is it not supported to put the DomainService class in it's own .NET Web Application? My thinking was this would then create an endpoint for RIA completely separate to the 'Main' Web App that actually shows the Silverlight control.

Is that where I am going wrong?

EDIT - I have also tried moving the Entity Model from it's own Class Library into the Web App that has the DomainService class, I still get the same issue. Do the DomainService, Entity Model, and the site that displays the Silverlight app all need to be in the same project? I.E All under the one web app?

Answers & Comments...

Answer: 1

By default silverlight(ria svc) uses binary endpoint.

WCF compress xml and it will be binary. Otherwise it could be heavy.

When I trace it in fiddler I always see /binary expressions on domain service calls. I also use EF. So binary should be in url.I think it should be configuration error.

Here is my request

/ClientBin/AHBSBus-Web-DomainSrv-DSrvSecurity.svc/binary/getServerDate

//request

< getServerDate xmlns="http://tempuri.org/"> < /getServerDate>

//response

< getServerDateResponse xmlns="http://tempuri.org/"> < getServerDateResult> 2013-01-24T15:53:13.4574466+02:00 < /getServerDateResponse>

http://blogs.msdn.com/b/saurabh/archive/2009/11/23/understanding-the-wcf-in-wcf-ria-services.aspx

The RIA Services ServiceHost creates the following endpoints by default -

a) For Silverlight Client: SOAP w/binary endpoint. Address = "binary", Binding = CustomBinding consisting of HttpTransportBindingElement and BinaryMessageEncodingBindingElement ..

You may trace your bindings by logging details. Put these lines in your web.config run your project and open log file.

<system.diagnostics>  <trace autoflush="true">      <listeners>      </listeners>  </trace>  <sources>      <source name="System.ServiceModel"              switchValue="Information, ActivityTracing"              propagateActivity="true">          <listeners>              <add name="sdt"                   type="System.Diagnostics.XmlWriterTraceListener"                   initializeData= "WcfDetailTrace.svclog" />          </listeners>      </source>  </sources>  

by : Davut Gürbüzhttp://stackoverflow.com/users/413032

Answer: 2

By default the Silverlight application is going to try and find the DomainService at the Application that is hosting it. If you want to have the DomainService at a different URL then you need to pass that URL into the constructor of the DomainContext.

If you are using a separate class library you need to make sure that the web application either references the class library or has the dll for the class library in the bin directory. You also need the RIA Services dlls and web.config setup. The easiest way now to do the later is to add the RiaServices.Server NuGet package to both the class library and the web application. The new package references the correct dlls and sets up the web.config.

by : Colin Blairhttp://stackoverflow.com/users/1633696




WCF sevice doesn't load in published application

WCF sevice doesn't load in published application

I have problem with Silverlight-enabled WCF service, so this is my service:

    [ServiceContract(Namespace = "")]             [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]             public class WhatsNewService             {                 string connectonString = ConfigurationManager.ConnectionStrings["sqlConnectionString"].ConnectionString;                  [OperationContract]                 public List<WhatsNewDataClass> GetData()                 {                     SqlConnection sqlCon = new SqlConnection(connectonString);                     DataSet objectSet = new DataSet();                     SqlCommand sqlCom = new SqlCommand();                     sqlCom.Connection = sqlCon;                     sqlCom.CommandText = "SELECT  * FROM [dbo].[WhatsNew] WHERE [rowStatus]='Unseen' ORDER BY [changeDate] ASC ;";                     SqlDataAdapter dataAdapter = new SqlDataAdapter();                     dataAdapter.SelectCommand = sqlCom;                     dataAdapter.Fill(objectSet);                     List<WhatsNewDataClass> result = new List<WhatsNewDataClass>();                     WhatsNewDataClass dataObject;                      if (objectSet.Tables.Count > 0)                     {                         foreach (DataRow dr in objectSet.Tables[0].Rows)                         {                                dataObject = new WhatsNewDataClass();                             dataObject.changeType = dr["changeType"].ToString();                             dataObject.objectType = dr["objectType"].ToString();                             dataObject.objectName = dr["objectName"].ToString();                             dataObject.changeDescription = dr["changeDescription"].ToString();                             dataObject.changeDate = dr["changeDate"].ToString();                             dataObject.changedBy = dr["changedBy"].ToString();                             dataObject.rowStatus = dr["rowStatus"].ToString();                             dataObject.ProjectID = dr["ProjectID"].ToString();                             dataObject.UserName = dr["UserName"].ToString();                             dataObject.itemID = dr["ID"].ToString();                             dataObject.refType = dr["refType"].ToString();                             dataObject.parentID = dr["parentID"].ToString();                              result.Add(dataObject);                          }                     }                   return result;             }   } 

So I call this service in my client part, everything is working fine, but when I publish it and put in my website, service don't return values. Any suggestions?

Answers & Comments...




how to manipulate CAD documents

how to manipulate CAD documents

I am working On a WebMapping Project . and i am using Silverlight (c#) . i have to manipulate some CAD documents (.STEP , .iges , .brep , .dxf) . is there any library to do that ?

Answers & Comments...




WriteableBitmap.Savejpeg does not render grid text (image is OK)

WriteableBitmap.Savejpeg does not render grid text (image is OK)

I have a Grid in a user control:

<Grid x:Name="LayoutRoot" Background="{StaticResource PhoneAccentBrush}">     <Image          x:Name="imgBack"         Opacity=".25" />     <Grid VerticalAlignment="Top" HorizontalAlignment="Left">         <Grid.RowDefinitions>             <RowDefinition Height="Auto" />             <RowDefinition Height="Auto" />             <RowDefinition Height="Auto" />             <RowDefinition Height="Auto" />             <RowDefinition Height="Auto" />             <RowDefinition Height="Auto" />         </Grid.RowDefinitions>         <Grid.ColumnDefinitions>             <ColumnDefinition Width="Auto" />         </Grid.ColumnDefinitions>         <!-- Some textblocks --> </Grid> 

The size of the grid & source of the image is set dynamically at runtime:

public void ChangeSizeAndImage(int width, int height, string backImagePath) {     // Set the height and width     LayoutRoot.Width = width;     LayoutRoot.Height = height;      // Set the background image     imgBack.Source = new BitmapImage(new Uri(backImagePath, UriKind.RelativeOrAbsolute));      this.UpdateLayout(); } 

I then call a method that generates a jpeg from the ui element & saves it to IsolatedStorage (later adding to a Windows Phone Live Tile)

public static Uri CreateImageFromUIElement(UIElement element, int width, int height) {     // Instance to store the image in     IsolatedStorageFile userStore = IsolatedStorageFile.GetUserStoreForApplication();      // Random ID to use for the file name     string id = Guid.NewGuid().ToString("n");      // create directory to read/write from     const string shellContentDirectory = "Shared\\ShellContent";     userStore.CreateDirectory(shellContentDirectory);      // Render the UIElement into a writeable bitmap     WriteableBitmap bitmap = new WriteableBitmap(element, new CompositeTransform());      // Save the bitmap to a file. This stream must be closed in order to be read later     string imagePath = shellContentDirectory + "\\" + id + ".jpg";     using (IsolatedStorageFileStream stream = userStore.OpenFile(imagePath, System.IO.FileMode.Create))     {         bitmap.SaveJpeg(stream, width, height, 0, 100);     }      // Uri to get us to the image     Uri imageUri = new Uri("isostore:/" + imagePath.Replace('\\', '/'));     return imageUri; } 

I'm able to successfully use the image on the tile, except I only see the image with a black background, and I don't see any of the text. I'm thinking that this has something to do with jpeg's and transparent PNG's, however, I'm setting the background on the Grid above with a color, so I'm not sure why it would be considered to be transparent.

Answers & Comments...




Merging Multiple IQueryables together - Silverlight

Merging Multiple IQueryables together - Silverlight

Peeps,

Im a born again virgin to Silverlight so please bear with me. I have two seperate DomainServices, pointing to two different SQL Database Servers. Within these Domain Services I have setup some IQueryables in each Domain Service.

I need to merge two IQueryables together from seperate DomainServices. Im sure this has got to be do-able.

Below are the two domain services.

I want to merge GetCustomCallLogs (from HEATLiveDomainService) together with GetTblCallsLogged (from HeatDomainService). The key in GetCustomCallLogs would be the CallID and the key in GetTblCallsLogged would be the RecID.

If its possible to do i understand i would need to create a new type to take into account any fields from the two joined tables.

Hopefully ive explained my scenario, and im not being dumb.

Thanks in advance

  public class HEATLIVEDomainService : LinqToEntitiesDomainService<HeatIT9_LiveEntities> {      // TODO:     // Consider constraining the results of your query method.  If you need additional input you can     // add parameters to this method or create additional query methods with different names.     // To support paging you will need to add ordering to the 'Assignees' query.     public IQueryable<Assignee> GetAssignees()     {         return this.ObjectContext.Assignees;     }      // TODO:     // Consider constraining the results of your query method.  If you need additional input you can     // add parameters to this method or create additional query methods with different names.     // To support paging you will need to add ordering to the 'CallLogs' query.     public IQueryable<CallLog> GetCallLogs()     {         //            return this.ObjectContext.CallLogs.Where(c => DateTime.Parse(c.ClosedDate).Year == 2012 && c.CallStatus == "Closed" && c.ClosedBy.Length > 0);         return this.ObjectContext.CallLogs.Where(c => c.CallStatus == "Closed" && c.ClosedDate.Substring(0, 4).Equals("2013"));     }      public IQueryable<CallLog> GetCallLogsLastThisYear()     {         return this.ObjectContext.CallLogs.Where(c => c.CallStatus == "Closed" && (c.ClosedDate.Substring(0, 4).Equals("2012") || c.ClosedDate.Substring(0, 4).Equals("2013")));     }      public IQueryable<CustomCallLog> GetCustomCallLogs(string year)     {         var result = from i in this.ObjectContext.CallLogs           join p in this.ObjectContext.Assignees on i.ClosedBy equals p.LoginID           where i.CallStatus == "Closed" && i.ClosedDate.Substring(0, 4) == year         select new CustomCallLog         {              Score =              CallLog = i.CallID,              Name = p.Assignee1,              Yr = year,             Mth = i.ClosedDate.Substring(5, 2),              GroupName = p.GroupName         };         return result;     }       public IQueryable<CustomClosedJobs> GetCustomClosedJobs()     {         var result = from i in this.ObjectContext.CallLogs                      where i.CallStatus == "Closed" && i.ClosedDate.Substring(0, 4) =="2012"                      group i by i.ClosedDate.Substring(5,2) into y                      select new CustomClosedJobs                      {                          Type = "heat",                          ClosedCalls = y.Count(),                           Mth =y.Key                      };         return result;     }       // TODO:     // Consider constraining the results of your query method.  If you need additional input you can     // add parameters to this method or create additional query methods with different names.     // To support paging you will need to add ordering to the 'Subsets' query.     public IQueryable<Subset> GetSubsets()     {         return this.ObjectContext.Subsets;     } }   public class HEATDomainService : LinqToEntitiesDomainService<FEEDBACKPRDEntities1> {      // TODO:     // Consider constraining the results of your query method.  If you need additional input you can     // add parameters to this method or create additional query methods with different names.     // To support paging you will need to add ordering to the 'qryStoringLogs' query.     public IQueryable<qryStoringLog> GetQryStoringLogs()     {         return this.ObjectContext.qryStoringLogs.OrderBy(e => e.monthno);     }      public IQueryable<tblStoringLog> GetTop100Logs()     {         return this.ObjectContext.tblStoringLogs.OrderByDescending(e => e.responsetime).Take(100);     }      public IQueryable<tblStoringLog> GetLogCount(DateTime s, DateTime e)     {         return this.ObjectContext.tblStoringLogs.Where(x => x.responsetime >= s &&  x.responsetime <= e);     }      public IQueryable<qryStoringLog> GetLogs(int year, int mth)     {         return this.ObjectContext.qryStoringLogs.Where(e => e.Month.Equals(mth) && e.yr.Equals(year));     }      public IQueryable<qryStoringLog> GetLogsForYear(int year)     {         return this.ObjectContext.qryStoringLogs.Where(e => e.yr.Equals(year)).OrderBy(e => e.monthno);     }      public DateTime GetFirstDate()     {         return (DateTime)this.ObjectContext.tblStoringLogs.OrderBy(e => e.responsetime).First().responsetime;     }      public DateTime GetLastDate()     {         return (DateTime)this.ObjectContext.tblStoringLogs.OrderByDescending(e => e.responsetime).First().responsetime;     }      public IQueryable<tblCallLogged> GetTblCallLoggeds()     {         return this.ObjectContext.tblCallLoggeds;     }      public IQueryable<tblStoringLog> GetTblStoringLogs()     {         return this.ObjectContext.tblStoringLogs;     }      [Query(IsComposable = false)]     public IQueryable<qryStoringLog> GetTblStoringLogsStatus(int statusid)     {         return this.ObjectContext.qryStoringLogs.Where(e => e.statusid == statusid);     }       public IQueryable<stResponsesLife_Result> LifeTimeResponses()     {         return this.ObjectContext.stResponsesLife().AsQueryable();     }       public IEnumerable<CustomLifetime> GetCustomLifeTime()     {         var result = from i in this.ObjectContext.stResponsesLife().ToList()                      select new CustomLifetime                      {                          Dates = i.Dates,                          Vals = (int)i.Vals                      };         return result;     }       public int GetAllResponses()     {         return this.ObjectContext.qryStoringLogs.Count();     }  } 

Caveats: Cannot have linked servers, so doing it at the source (SQL Server) is out of the question. Cannot create a SP and use OpenQuery (well i could but i want to learn to do it correctly), as im sure this isnt the correct way of doing it.

Answers & Comments...




System.Xml.Linq, Portable Libraries and Silverlight

System.Xml.Linq, Portable Libraries and Silverlight

I built a portable class library (profile47, which includes Silverlight 5) that references System.Xml.Linq. I can reference that portable library from my Silverlight 5 application, and I can reference the Silverlight version of System.Xml.Linq in C:\Program Files (x86)\Microsoft SDKs\Silverlight\v5.0\Libraries\Client. The problem is that that System.Xml.Linq dll has a different version number (5.0.5.0) than the one referenced by the portable library, and when I run the Silverlight app it throws an exception:

Could not load file or assembly 'System.Xml.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. The system cannot find the file specified. 

As there isn't an assembly redirect mechanism in app.config like in full .NET framework, is there any way to make this work?

Answers & Comments...

Answer: 1

Remove the System.Xml.Linq reference from your portable class library. The .Net Portable Subset is enough if you have .net framework 4.0.3 in your profile.

by : Paulhttp://stackoverflow.com/users/85325




pdf docs in silverlight

pdf docs in silverlight

I have a requirement. I have to enable users to attach documents and that will get saved in the db in binary format.

Now the challenge is, I have to display the document list in the silverlight application and when user clicks on any of the link it should not ask for downloading the document instead it should open the document in the next tab. (the document could be pdf, png, excel, doc).

I have gone through multiple threads but all those thread ends on either third party tool or OOB. I cannot have OOB enabled.

I just want to check is there any way we can achieve this using silverlights inbuilt functions.

Answers & Comments...

Answer: 1

I think a combination of @Blam's comment of sending the proper mime type coupled with a Silverlight HyperlinkButton with the Target set for the new window would be your ticket. The XAML would look like this :

<HyperlinkButton Content="Name of PDF" Target="PDFWindow" NavigateUri="/DownloadPDF.aspx?id=BINDING OF UNIQUE ID" /> 

You'd add a page to your Silverlight project called DownloadPDF and it would take in one argument in the request variables; the unique ID of the PDF to grab from the database. DownloadPDF would change the mime type to "application/pdf" and then write the bytes from the SQL server to the response stream.

by : Joshhttp://stackoverflow.com/users/62623




Where can I find the "Silverlight Developer Runtime" for Silverlight 5?

Where can I find the "Silverlight Developer Runtime" for Silverlight 5?

I need to remote debug a Silverlight application that's running on a Mac. According to Microsoft's walkthrough I need to install the developer runtime on the Mac.

I've been Googling for a while now but I can't find an up to date version. This question has links to version 4 and a beta for version 5, but nothing for the current version.

Answers & Comments...

Answer: 1

Try this: Silverlight 5 Developer Runtime for Mac OSX (32 bit)

by : Memoizerhttp://stackoverflow.com/users/1937750




How to use code contracts in the silverlight project (best practices)

How to use code contracts in the silverlight project (best practices)

What are the best practices for using code contracts in the silverlight (4 or 5) Project? Which settings are the best for the code-contracts for the debug and release?

I use CONTRACTS_FULL, Standard Contract Requires and Build Contract Reference Assembly for the debug only, and avoid the Contract.Requires. But I'm not sure if this is the best approach for the silverlight project.

Is the code contracts better for the silverlight Project as another alternatives (like the ReSharper Attributes, "if then throw" ...)?

Answers & Comments...