Search Results

Search found 16 results on 1 pages for 'rasx'.

Page 1/1 | 1 

  • CollectionViewSource.GetDefaultView is not in Silverlight 3! What's the work-around?

    - by rasx
    The CollectionViewSource.GetDefaultView() method is not in Silverlight 3. In WPF I have this extension method: public static void SetActiveViewModel<ViewModelType>(this ViewModelBase viewModel, ViewModelType collectionItem, ObservableCollection<ViewModelType> collection) where ViewModelType : ViewModelBase { Debug.Assert(collection.Contains(collectionItem)); ICollectionView collectionView = CollectionViewSource.GetDefaultView(collection); if(collectionView != null) collectionView.MoveCurrentTo(collectionItem); } How can this be written in Silverlight 3?

    Read the article

  • Shawn Wildermuth violating MVVM in MSDN article?

    - by rasx
    This may be old news but back in March 2009, Shawn Wildermuth, his article, “Model-View-ViewModel In Silverlight 2 Apps,” has a code sample that includes DataServiceEntityBase: // COPIED FROM SILVERLIGHTCONTRIB Project for simplicity /// <summary> /// Base class for DataService Data Contract classes to implement /// base functionality that is needed like INotifyPropertyChanged. /// Add the base class in the partial class to add the implementation. /// </summary> public abstract class DataServiceEntityBase : INotifyPropertyChanged { /// <summary> /// The handler for the registrants of the interface's event /// </summary> PropertyChangedEventHandler _propertyChangedHandler; /// <summary> /// Allow inheritors to fire the event more simply. /// </summary> /// <param name="propertyName"></param> protected void FirePropertyChanged(string propertyName) { if (_propertyChangedHandler != null) { _propertyChangedHandler(this, new PropertyChangedEventArgs(propertyName)); } } #region INotifyPropertyChanged Members /// <summary> /// The interface used to notify changes on the entity. /// </summary> event PropertyChangedEventHandler INotifyPropertyChanged.PropertyChanged { add { _propertyChangedHandler += value; } remove { _propertyChangedHandler -= value; } } #endregion What this class implies is that the developer intends to bind visuals directly to data (yes, a ViewModel is used but it defines an ObservableCollection of data objects). Is this design diverging too far from the guidance of MVVM? Now I can see some of the reasons why Shawn would go this way: what Shawn can do with DataServiceEntityBase is this sort of thing (which is intimate with the Entity Framework): // Partial Method to support the INotifyPropertyChanged interface public partial class Game : DataServiceEntityBase { #region Partial Method INotifyPropertyChanged Implementation // Override the Changed partial methods to implement the // INotifyPropertyChanged interface // This helps with the Model implementation to be a mostly // DataBound implementation partial void OnDeveloperChanged() { base.FirePropertyChanged("Developer"); } partial void OnGenreChanged() { base.FirePropertyChanged("Genre"); } partial void OnListPriceChanged() { base.FirePropertyChanged("ListPrice"); } partial void OnListPriceCurrencyChanged() { base.FirePropertyChanged("ListPriceCurrency"); } partial void OnPlayerInfoChanged() { base.FirePropertyChanged("PlayerInfo"); } partial void OnProductDescriptionChanged() { base.FirePropertyChanged("ProductDescription"); } partial void OnProductIDChanged() { base.FirePropertyChanged("ProductID"); } partial void OnProductImageUrlChanged() { base.FirePropertyChanged("ProductImageUrl"); } partial void OnProductNameChanged() { base.FirePropertyChanged("ProductName"); } partial void OnProductTypeIDChanged() { base.FirePropertyChanged("ProductTypeID"); } partial void OnPublisherChanged() { base.FirePropertyChanged("Publisher"); } partial void OnRatingChanged() { base.FirePropertyChanged("Rating"); } partial void OnRatingUrlChanged() { base.FirePropertyChanged("RatingUrl"); } partial void OnReleaseDateChanged() { base.FirePropertyChanged("ReleaseDate"); } partial void OnSystemNameChanged() { base.FirePropertyChanged("SystemName"); } #endregion } Of course MSDN code can seen as “toy code” for educational purposes but is anyone doing anything like this in the real world of Silverlight development?

    Read the article

  • Silverlight 3 Binding to the Current Item in a Collection

    - by rasx
    The Binding syntax, {Binding /}, works in WPF but does not work at all in Silverlight 3: <ContentControl Content="{Binding MyCollection}"> <ContentControl.ContentTemplate> <DataTemplate> <ContentControl Content="{Binding /}" /> </DataTemplate> </ContentControl.ContentTemplate> </ContentControl> What's the way to approach this in Silverlight?

    Read the article

  • Custom Logic and Proxy Classes in ADO.NET Data Services

    - by rasx
    I've just read "Injecting Custom Logic in ADO.NET Data Services" and my next question is, How do you get your [WebGet] method to show up in the client-side proxy classes? Sure, I can call this directly (RESTfully) with, say, WebClient but I thought the strong typing features in ADO.NET Data Services would "hide" this from me auto-magically. So here we have: public class MyService : DataService<MyDataSource> { // This method is called only once to initialize service-wide policies. public static void InitializeService(IDataServiceConfiguration config) { config.SetEntitySetAccessRule("Customers", EntitySetRights.AllRead); config.SetServiceOperationAccessRule("CustomersInCity", ServiceOperationRights.All); } [WebGet] public IQueryable<MyDataSource.Customers> CustomersInCity(string city) { return from c in this.CurrentDataSource.Customers where c.City == city select c; } } How can I get CustomersInCity() to show up in my client-side class defintions?

    Read the article

  • Does MS PnP Unity Scan for Assemblies Like StructureMap?

    - by rasx
    In Using StructureMap 2.5 to scan all assemblies in a folder, we can see that StructureMap uses AssembliesFromPath() to explicitly look for types to resolve. What is the equivalent of this in Microsoft Unity? Because Unity is such a generic term, searching for documents about this online is not that easy. Update: Unity has something called an Assembly Matching Rule but its description does not communicate to me that it scans folders.

    Read the article

  • Does this MSDN article violate MVVM?

    - by rasx
    This may be old news but back in March 2009, this article, “Model-View-ViewModel In Silverlight 2 Apps,” has a code sample that includes DataServiceEntityBase: // COPIED FROM SILVERLIGHTCONTRIB Project for simplicity /// <summary> /// Base class for DataService Data Contract classes to implement /// base functionality that is needed like INotifyPropertyChanged. /// Add the base class in the partial class to add the implementation. /// </summary> public abstract class DataServiceEntityBase : INotifyPropertyChanged { /// <summary> /// The handler for the registrants of the interface's event /// </summary> PropertyChangedEventHandler _propertyChangedHandler; /// <summary> /// Allow inheritors to fire the event more simply. /// </summary> /// <param name="propertyName"></param> protected void FirePropertyChanged(string propertyName) { if (_propertyChangedHandler != null) { _propertyChangedHandler(this, new PropertyChangedEventArgs(propertyName)); } } #region INotifyPropertyChanged Members /// <summary> /// The interface used to notify changes on the entity. /// </summary> event PropertyChangedEventHandler INotifyPropertyChanged.PropertyChanged { add { _propertyChangedHandler += value; } remove { _propertyChangedHandler -= value; } } #endregion What this class implies is that the developer intends to bind visuals directly to data (yes, a ViewModel is used but it defines an ObservableCollection of data objects). Is this design diverging too far from the guidance of MVVM? Now I can see some of the reasons Why would we go this way: what we can do with DataServiceEntityBase is this sort of thing (which is intimate with the Entity Framework): // Partial Method to support the INotifyPropertyChanged interface public partial class Game : DataServiceEntityBase { #region Partial Method INotifyPropertyChanged Implementation // Override the Changed partial methods to implement the // INotifyPropertyChanged interface // This helps with the Model implementation to be a mostly // DataBound implementation partial void OnDeveloperChanged() { base.FirePropertyChanged("Developer"); } partial void OnGenreChanged() { base.FirePropertyChanged("Genre"); } partial void OnListPriceChanged() { base.FirePropertyChanged("ListPrice"); } partial void OnListPriceCurrencyChanged() { base.FirePropertyChanged("ListPriceCurrency"); } partial void OnPlayerInfoChanged() { base.FirePropertyChanged("PlayerInfo"); } partial void OnProductDescriptionChanged() { base.FirePropertyChanged("ProductDescription"); } partial void OnProductIDChanged() { base.FirePropertyChanged("ProductID"); } partial void OnProductImageUrlChanged() { base.FirePropertyChanged("ProductImageUrl"); } partial void OnProductNameChanged() { base.FirePropertyChanged("ProductName"); } partial void OnProductTypeIDChanged() { base.FirePropertyChanged("ProductTypeID"); } partial void OnPublisherChanged() { base.FirePropertyChanged("Publisher"); } partial void OnRatingChanged() { base.FirePropertyChanged("Rating"); } partial void OnRatingUrlChanged() { base.FirePropertyChanged("RatingUrl"); } partial void OnReleaseDateChanged() { base.FirePropertyChanged("ReleaseDate"); } partial void OnSystemNameChanged() { base.FirePropertyChanged("SystemName"); } #endregion } Of course MSDN code can seen as “toy code” for educational purposes but is anyone doing anything like this in the real world of Silverlight development?

    Read the article

  • MemoryStream, XmlTextWriter and Warning 4 CA2202 : Microsoft.Usage

    - by rasx
    The Run Code Analysis command in Visual Studio 2010 Ultimate returns a warning when seeing a certain pattern with MemoryStream and XmlTextWriter. This is the warning: Warning 7 CA2202 : Microsoft.Usage : Object 'ms' can be disposed more than once in method 'KinteWritePages.GetXPathDocument(DbConnection)'. To avoid generating a System.ObjectDisposedException you should not call Dispose more than one time on an object.: Lines: 421 C:\Visual Studio 2010\Projects\Songhay.DataAccess.KinteWritePages\KinteWritePages.cs 421 Songhay.DataAccess.KinteWritePages This is the form: static XPathDocument GetXPathDocument(DbConnection connection) { XPathDocument xpDoc = null; var ms = new MemoryStream(); try { using(XmlTextWriter writer = new XmlTextWriter(ms, Encoding.UTF8)) { using(DbDataReader reader = CommonReader.GetReader(connection, Resources.KinteRssSql)) { writer.WriteStartDocument(); writer.WriteStartElement("data"); do { while(reader.Read()) { writer.WriteStartElement("item"); for(int i = 0; i < reader.FieldCount; i++) { writer.WriteRaw(String.Format("<{0}>{1}</{0}>", reader.GetName(i), reader[i].ToString())); } writer.WriteFullEndElement(); } } while(reader.NextResult()); writer.WriteFullEndElement(); writer.WriteEndDocument(); writer.Flush(); ms.Position = 0; xpDoc = new XPathDocument(ms); } } } finally { ms.Dispose(); } return xpDoc; } The same kind of warning is produced for this form: XPathDocument xpDoc = null; using(var ms = new MemoryStream()) { using(XmlTextWriter writer = new XmlTextWriter(ms, Encoding.UTF8)) { using(DbDataReader reader = CommonReader.GetReader(connection, Resources.KinteRssSql)) { //... } } } return xpDoc; By the way, the following form produces another warning: XPathDocument xpDoc = null; var ms = new MemoryStream(); using(XmlTextWriter writer = new XmlTextWriter(ms, Encoding.UTF8)) { using(DbDataReader reader = CommonReader.GetReader(connection, Resources.KinteRssSql)) { //... } } return xpDoc; The above produces the warning: Warning 7 CA2000 : Microsoft.Reliability : In method 'KinteWritePages.GetXPathDocument(DbConnection)', object 'ms' is not disposed along all exception paths. Call System.IDisposable.Dispose on object 'ms' before all references to it are out of scope. C:\Visual Studio 2010\Projects\Songhay.DataAccess.KinteWritePages\KinteWritePages.cs 383 Songhay.DataAccess.KinteWritePages In addition to the following, what are my options?: Supress warning CA2202. Supress warning CA2000 and hope that Microsoft is disposing of MemoryStream (because Reflector is not showing me the source code). Rewrite my legacy code to recognize the wonderful XDocument and LINQ to XML.

    Read the article

  • What ASP.NET MVC Route controls the appearance of hashes in URIs?

    - by rasx
    I have integrated a Silverlight Navigation Application in an ASP.NET MVC web. However when Silverlight calls for its default page, say, IndexPage ASP.NET MVC displays the route as: http://localhost/#/IndexPage I have tried to get ASP.NET MVC to respond to this route: http://localhost/#IndexPage but I am unable to find a configuration that works with this. Does ASP.NET MVC routes respond to hashes in general?

    Read the article

  • Do you prefer a Grid of ContentControl elements?

    - by rasx
    Today I am led to say for the greatest level of flexibility using a Grid of ContentControl elements is the way to go. Are there any caveats coming for choosing this strategy? (Note that, of course, I am not referring to the DataGrid or the GridView of a ListView.)

    Read the article

  • Silverlight error-handling conventions: There is no relationship between onSilverlightError and Repo

    - by rasx
    When I see the call System.Windows.Browser.HtmlPage.Window.Eval (which is evil) in ReportErrorToDOM (in App.xaml.cs) this shows me that it has no relationship to onSilverlightError. So what kind of JavaScript-based scenario calls onSilverlightError? When will onSilverlightError definitely be needed? What are Silverlight error-handling conventions in general? This is a very important comment by Erik Monk but needs more detail: There are 2 kinds of terminal errors in Silverlight. 1) Managed errors (hit the managed Application_UnhandledException method). Note that some errors may not even get to this point. If the managed infrastructure can't be loaded for some reason (out of memory error maybe...), you won't get this kind of error. Still, if you can get it, you can use a web service (or the CLOG project) to communicate it back to the server. 2) Javascript errors.

    Read the article

  • Trying to get a better understanding of SelectedValuePath and IsSynchronizedWithCurrentItem

    - by rasx
    The following XAML produces a run-time Binding error when I click on an item in the ListBox: <Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:sys="clr-namespace:System;assembly=mscorlib" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" x:Class="WpfApplication1.MainWindow" x:Name="Window" Title="MainWindow" Width="640" Height="480"> <Window.Resources> <x:Array x:Key="strings" Type="{x:Type sys:String}"> <sys:String>one</sys:String> <sys:String>two</sys:String> <sys:String>three</sys:String> <sys:String>four</sys:String> </x:Array> </Window.Resources> <Grid> <ListBox DataContext="{StaticResource strings}" IsSynchronizedWithCurrentItem="True" ItemsSource="{Binding}" SelectedValuePath="{Binding /Length}"> <ListBox.ItemTemplate> <DataTemplate> <Grid> <Grid.Resources> <Style TargetType="{x:Type Label}"> <Setter Property="Background" Value="Yellow"/> <Setter Property="Margin" Value="0,0,4,0"/> <Setter Property="Padding" Value="0"/> </Style> </Grid.Resources> <Grid.ColumnDefinitions> <ColumnDefinition/> <ColumnDefinition/> </Grid.ColumnDefinitions> <Grid.RowDefinitions> <RowDefinition/> <RowDefinition/> </Grid.RowDefinitions> <!-- Row 0 --> <Label Grid.Column="0" Grid.Row="0">String:</Label> <TextBlock Grid.Column="1" Grid.Row="0" Text="{Binding}"/> <!-- Row 1 --> <Label Grid.Column="0" Grid.Row="1">Length:</Label> <TextBlock Grid.Column="1" Grid.Row="1" Text="{Binding Length, Mode=Default}"/> </Grid> </DataTemplate> </ListBox.ItemTemplate> </ListBox> </Grid> </Window> This is the run-time Binding error message: System.Windows.Data Error: 39 : BindingExpression path error: '3' property not found on 'object' ''String' (HashCode=1191344027)'. BindingExpression:Path=3; DataItem='String' (HashCode=1191344027); target element is 'ListBox' (Name=''); target property is 'NoTarget' (type 'Object') I would like the selected value of the ListBox to be the Length of the selected String object. What is wrong with my SelectedValuePath Binding syntax? Are there any related issues with IsSynchronizedWithCurrentItem?

    Read the article

  • Did the Unity Team fix that "generics handling" bug back in 2008?

    - by rasx
    At my level of experience with Unity it might be faster to ask whether the "generics handling" bug acknowledged by ctavares back in 2008 was fixed in a public release. Here was the problem (which might be my problem today): Hi, I get an exception when using .... container.RegisterType(typeof(IDictionary<,), typeof(Dictionary<,)); The exception is... "Resolution of the dependency failed, type = \"IDictionary2\", name = \"\". Exception message is: The current build operation (build key Build Key[System.Collections.Generic.Dictionary2[System.String,System.String], null]) failed: The current build operation (build key Build Key[System.Collections.Generic.Dictionary2[System.String,System.String], null]) failed: The type Dictionary2 has multiple constructors of length 2. Unable to disambiguate. When I attempt... IDictionary myExampleDictionary = container.Resolve(); Here was the moderated response: There are no books that'll help, Unity is a little too new for publishers to have caught up yet. Unfortunately, you've run into a bug in our generics handling. This is currently fixed in our internal version, but it'll be a little while before we can get the bits out. In the meantime, as a workaround you could do something like this instead: public class WorkaroundDictionary : Dictionary { public WorkaroundDictionary() { } } container.RegisterType(typeof(IDictionary<,),typeof(WorkaroundDictionary<,)); The WorkaroundDictionary only has the default constructor so it'll inject no problem. Since the rest of your app is written in terms of IDictionary, when we get the fixed version done you can just replace the registration with the real Dictionary class, throw out the workaround, and everything will still just work. Sorry about the bug, it'll be fixed soon!

    Read the article

  • Gratuitous use of System.Runtime.Serialization attributes?

    - by rasx
    Is there any cost/drawback (apart from typing too much) to adorning a class with System.Runtime.Serialization attributes (like [DataContract]) such that it can be used locally as a direct reference to a desktop Client project or as a type for a WCF service? The goal here is to write a data-tier class that can be used in both rich client (WPF) and Web scenarios. My data classes will be in a project that is separate from Client and WCF (*.svc code-behind) code. Is this a valid attempt to reuse code?

    Read the article

  • jQuery plugin: Validation can't be customized without setting all fields to 'required'?

    - by rasx
    I've spent the day looking at jQuery plugin: Validation by Jörn Zaefferer. I notice that it works fine as long as you call the validate() method without options. In my little squalid world, as soon as I add options, like errorPlacement, I notice that validation ignores form fields that are not marked required. I also notice that many, many demos mark all fields required---or do not pass options. Am I writing about anything familiar here? Or should I astral project to a parallel universe?

    Read the article

1