Search Results

Search found 61 results on 3 pages for 'shimmy'.

Page 2/3 | < Previous Page | 1 2 3  | Next Page >

  • How to aggregate over few types with linq?

    - by Shimmy
    Can someone help me translate the following to one liner: Dim items As New List(Of Object) For Each c In ph.Contacts items.Add(New With {.Type = "Contact", .Id = c.ContactId, .Title = c.Title}) Next For Each c In ph.Persons items.Add(New With {.Type = "Person", .Id = c.PersonId, .Title = c.Title}) Next For Each c In ph.Jobs items.Add(New With {.Type = "Job", .Id = c.JobId, .Title = c.Title}) Next Is it possible to merge them all into one query or method line, I don't really care if this will be done with something other than linq, I am just looking for a more efficient way as I have a long list coming ahead, and the aggregating list will be strongly-typed using Dim list = blah blah

    Read the article

  • Dictionary looping performance comparison

    - by Shimmy
    I have the following 3 options, I believe there are more: For Each entry In Me Next For i = 0 To Count Dim key = Keys(0) Dim value = Values(0) Next For Each Key In Keys Dim value = Me(Key) Next Personally, I think the For Each is best since the GetEnumerator is TKey, TValue based, but I donnu.

    Read the article

  • Find ListBox from its child?

    - by Shimmy
    How do I extract the parent container of a ListBoxItem? In the following example I can go till the ListBoxItem, higher than that I get Nothing: <ListBox Name="lbAddress"> <ListBox.ItemTemplate> <DataTemplate> <Button Click="Button_Click"/> </DataTemplate> </ListBox.ItemTemplate> </ListBox> Private Sub Button_Click(sender As Button, e As RoutedEventArgs) Dim lbAddress = GetAncestor(Of ListBox) 'Result: Nothing End Sub Public Shared Function GetAncestor(Of T)(reference As DependencyObject) As T Dim parent = GetParent(reference) While parent IsNot Nothing AndAlso Not parent.GetType.Equals(GetType(T)) parent = GetVisualAncestor(Of T)(parent) End While If parent IsNot Nothing Then _ Return If(parent.GetType Is GetType(T), parent, Nothing) Return Nothing End Sub Public Function GetParent(reference As DependencyObject) As DependencyObject Dim parent As DependencyObject = Nothing If TypeOf reference Is FrameworkElement Then parent = DirectCast(reference, FrameworkElement).Parent ElseIf TypeOf reference Is FrameworkContentElement Then parent = DirectCast(reference, FrameworkContentElement).Parent End If Return If(parent, VisualTreeHelper.GetParent(reference)) End Function

    Read the article

  • Nested ComboBox doesn't update source by selection.

    - by Shimmy
    Hello. I am using a ComboBox bound under a DataContext: <tk:DataGridTemplateColumn.CellEditingTemplate> <DataTemplate> <ComboBox ItemsSource="{Binding Source={StaticResource CategoriesCollection}" DisplayMemberPath="Title" SelectedItem="{Binding Category}" /> </DataTemplate> </tk:DataGridTemplateColumn.CellEditingTemplate> When the row is initiated the value of Category is null. Once I select the first value in the ComboBox it sets it up. But when I select another value, it doesn't get changed.

    Read the article

  • Problem with custom Equality and GetHashCode in a mutable object

    - by Shimmy
    Hello! I am using Entity Framework in my application. I implemented with the partial class of an entity the IEquatable<T> interface: Partial Class Address : Implements IEquatable(Of Address) 'Other part generated Public Overloads Function Equals(ByVal other As Address) As Boolean _ Implements System.IEquatable(Of Address).Equals If ReferenceEquals(Me, other) Then Return True Return AddressId = other.AddressId End Function Public Overrides Function Equals(ByVal obj As Object) As Boolean If obj Is Nothing Then Return MyBase.Equals(obj) If TypeOf obj Is Address Then Return Equals(DirectCast(obj, Address)) Else Return False End Function Public Overrides Function GetHashCode() As Integer Return AddressId.GetHashCode End Function End Class Now in my code I use it this way: Sub Main() Using e As New CompleteKitchenEntities Dim job = e.Job.FirstOrDefault Dim address As New Address() job.Addresses.Add(address) Dim contains1 = job.Addresses.Contains(address) 'True e.SaveChanges() Dim contains2 = job.Addresses.Contains(address) 'False 'The problem is that I can't remove it: Dim removed = job.Addresses.Remoeve(address) 'False End Using End Sub Note (I checked in the debugger visualizer) that the EntityCollection class stores its entities in HashSet so it has to do with the GetHashCode function, I want it to depend on the ID so entities are compared by their IDs. The problem is that when I hit save, the ID changes from 0 to its db value. So the question is how can I have an equatable object, being properly hashed. Please help me find what's wrong in the GetHashCode function (by ID) and what can I change to make it work. Thanks a lot.

    Read the article

  • GetHashCode on null fields?

    - by Shimmy
    How do I deal with null fields in GetHashCode function? Module Module1 Sub Main() Dim c As New Contact Dim hash = c.GetHashCode End Sub Public Class Contact : Implements IEquatable(Of Contact) Public Name As String Public Address As String Public Overloads Function Equals(ByVal other As Contact) As Boolean _ Implements System.IEquatable(Of Contact).Equals Return Name = other.Name AndAlso Address = other.Address End Function Public Overrides Function Equals(ByVal obj As Object) As Boolean If ReferenceEquals(Me, obj) Then Return True If TypeOf obj Is Contact Then Return Equals(DirectCast(obj, Contact)) Else Return False End If End Function Public Overrides Function GetHashCode() As Integer Return Name.GetHashCode Xor Address.GetHashCode End Function End Class End Module

    Read the article

  • How to make route-commands execute in the global application scope rather than locally in a page or

    - by Shimmy
    Hello! I created a window that contains a frame, and above the frame it contains a button that its Command property is set to "Refresh". In the page shown in the frame, I set a CommandBinding for Refresh. I want that when the 'Refresh' command is executed it should be caught by the page Refresh_Executed event-handler set in the CommandBinding. In other words, Is there a way to set global Commands that are targeted for the entire application scope and execute everywhere they're bound?

    Read the article

  • Add new row: ListView vs. DataGrid

    - by Shimmy
    Hello! I have been looking around and even found a couple of related answers and didn't get a certain answer to my question. Is there a way to have in the WPF ListView an additional row like in a DataGrid? I prefer using the ListView since I use 3.5 and the DataGrid is not officially in the box and has many quirks. I would prefer using the ListView if there is an official option to add new rows or else I use the DataGrid. Thanks a lot.

    Read the article

  • Ultimate chat-client API for .NET?

    - by Shimmy
    Does anyone know of a .NET API (source-code is preferrable of course) that I can access all the common chat clients thru it (GT, Yahoo, MSN, AIM, FB, ICQ, SKYPE and more)? I guess I am looking for a .NET library project that performs something like pidjin. I need it because I hate Pidgin's interface and functionality, and I want to have a Google-Talk desktop like UI. Any comments and tips will also be very useful. Thanks.

    Read the article

  • Unable to use Client Application Services with custom MembershipProvider.

    - by Shimmy
    Hi, I have a Windows-Forms Application that I configured to use with an ASP.NET Service that is an Authentication service using a custom MembershipProvider. When I call Membership.CreateUser in the Windows Application a NotSupportedException is thrown telling: "Specified method is not supported.". I tried creating a web page in the website and test the MembershipProvider, everything works just fine when woeking from within the website. Any ideas or link for how to use custom (not SqlMembershipProvider) MembershipProvider will be really appreciated! Edit: The method ValidateUser does work. The overriden CreateUser doesn't work I tried Override Sub CreateUser(.......) As MembershipUser Return New User() End Sub But I still get the same excetption as before.

    Read the article

  • How do I get the ListBox from a ListBoxItem?

    - by Shimmy
    Sub FindAncestor(Of TParent, reference As DependencyObject) As TParent 'find the parent ListBox container End Sub 'Usage Sub Handle(lbi As ListBoxItem) Dim lb = GetListBox(lbi) End Sub I have a button in a ListBoxItem datatemplate, I want in the handler of the button to access the parent ListBox (this is the way I want to access it, since it's all nested in other DataTemplates, ItemsControls and stuff).

    Read the article

  • How to implement IEquatable<T> when mutable fields are part of the equality - Problem with GetHashCo

    - by Shimmy
    Hello! I am using Entity Framework in my application. I implemented with the partial class of an entity the IEquatable<T> interface: Partial Class Address : Implements IEquatable(Of Address) 'Other part generated Public Overloads Function Equals(ByVal other As Address) As Boolean _ Implements System.IEquatable(Of Address).Equals If ReferenceEquals(Me, other) Then Return True Return AddressId = other.AddressId End Function Public Overrides Function Equals(ByVal obj As Object) As Boolean If obj Is Nothing Then Return MyBase.Equals(obj) If TypeOf obj Is Address Then Return Equals(DirectCast(obj, Address)) Else Return False End Function Public Overrides Function GetHashCode() As Integer Return AddressId.GetHashCode End Function End Class Now in my code I use it this way: Sub Main() Using e As New CompleteKitchenEntities Dim job = e.Job.FirstOrDefault Dim address As New Address() job.Addresses.Add(address) Dim contains1 = job.Addresses.Contains(address) 'True e.SaveChanges() Dim contains2 = job.Addresses.Contains(address) 'False 'The problem is that I can't remove it: Dim removed = job.Addresses.Remoeve(address) 'False End Using End Sub Note (I checked in the debugger visualizer) that the EntityCollection class stores its entities in HashSet so it has to do with the GetHashCode function, I want it to depend on the ID so entities are compared by their IDs. The problem is that when I hit save, the ID changes from 0 to its db value. So the question is how can I have an equatable object, being properly hashed. Please help me find what's wrong in the GetHashCode function (by ID) and what can I change to make it work. Thanks a lot.

    Read the article

  • Lazy/deferred loading of a CollectionViewSource?

    - by Shimmy
    When you create a CollectionViewSource in the Resources section, is the set Source loaded when the resources are initalized (i.e. when the Resources holder is inited) or when data is bound? Is there a xamly way to make a CollectionViewSource lazy-load? deferred-load? explicit-load?

    Read the article

  • Cascading IEquatable(Of T)

    - by Shimmy
    Hello! I have several entities I need to make IEquatable(Of TEntity) respectively. I want them first to check equality between EntityId, then if both are zero, should check regarding to other properties, for example same contact names, same phone number etc. How is this done?

    Read the article

  • How to handle a DataTemplate creation

    - by Shimmy
    Hello! Take a look at the following xaml: <ListBox ItemsSource="{Binding}"> <ListBox.Resources> <CollectionViewSource x:Key="CVS"/> </ListBox.Resources> <ListBox.DataTemplate> <DataTemplate OnBinding="myBinding"> <ListBox DataContext="{StaticResource CVS}" ItemsSource="{Binding}" /> </DataTemplate> </ListBox.DataTemplate> </ListBox> So I can handle the binding and manually retrieve the CVS and set its Source property to my custom stuff according to the DataTemplate's DataContext. Or else there is a different way in doing it. Any ideas are welcommed!

    Read the article

  • Load WPF styles (static resources) from an external assembly

    - by Shimmy
    I have a few WPF applications and I want all my styles to be in a shared assembly instead of declaring them in each application separately. I am looking for a way so I don't have to change all my Style="{StaticResource BlahBlah}" in the existing applications; I just want to add the reference to this style assembly, and delete it from the current application, so it's taken from the assembly. Is there any way?

    Read the article

  • Cannot delete from sys.tables

    - by Shimmy
    How can I perform this query on whatever way: delete from sys.tables where is_ms_shipped = 0 What happened is, I executed a very large query and I forgot to put USE directive on top of it, now I got a zillion tables on my master db, and don't want to delete them one by one. UPDATE: It's a brand new database, so I don't have to care about any previous data, the final result I want to achieve is to reset the master db to factory shipping.

    Read the article

  • Is there a way to make a serialized member to serialize as an attribute?

    - by Shimmy
    Is there a way to make a serialized member to serialize as an attribute: <Serializable> Public Class Person Public Property Name As String End Class I want than when this class is xml-serialized, it should produce: <Person Name="John Doe" /> And what I mean is that instead of the Name property should be serialized as an element, it should be serialized as an xml attribute.

    Read the article

  • How can I make a multi search SPROC/UDF by passing a tabled-value to it?

    - by Shimmy
    I actually want to achieve the following description This is the table argument I want to pass to the server <items> <item category="cats">1</item> <item category="dogs">2</item> </items> SELECT * FROM Item WHERE Item.Category = <one of the items in the XML list> AND Item.ReferenceId = <the corresponding value of that item xml element> --Or in other words: SELECT FROM Items WHERE Item IN XML according to the splecified columns. Am I clear enought? I don't mind to do it in a different way other than xml. What I need is selecting values that mach an array of two of its columns' values.

    Read the article

  • Dynamic/Generic ViewModelBase?

    - by Shimmy
    I am learning MVVM now and I understand few things (more than but few are here..): Does every model potentially exposed (thru a VM) to the View is having a VM? For example, if I have a Contact and Address entity and each contact has an Addresses (many) property, does it mean I have to create a ContactViewModel and an AddressViewModel etc.? Do I have to redeclare all the properties of the Model again in the ViewModel (i.e. FirstName, LastName blah blah)? why not have a ViewModelBase and the ContactViewMode will be a subclass of ViewModelBase accessing the Entity's properties itself? and if this is a bad idea that the View has access to the entity (please explain why), then why not have the ViewModelBase be a DynamicObject (view the Dictionary example @ the link page), so I don't have to redeclare all the properties and validation over and over in the two tiers (M & VM) - because really, the View is anyway accessing the ViewModel's fields via reflection anyway. I think MVVM was the hardest technology I've ever learned. it doesn't have out-the-box support and there are to many frameworks and methods to achieve it, and in the other hand there is no arranged way to learn it (as MVC for instance), learning MVVM means browsing and surfing around trying to figure out what's better. Bottom line, what I mean by this section is please go and vote to MSFT to add MVVM support in the BCL and generators for VMs and Vs according to the Ms. Thanks

    Read the article

  • Unable to add PageFunction to my project.

    - by Shimmy
    I add to my project a PageFunction and I get a dozen of the following error and the project won't compile: 'ResourceDictionary' root element is a generic type and requires a x:Class attribute to support the x:TypeArguments attribute specified on the root element tag. Basically I get an error for each DataTemplate I merge in the ResourceDictionary, has anyone encoutered this problem before? Note: I use VB.NET 3.5 on VS 2010.

    Read the article

< Previous Page | 1 2 3  | Next Page >