Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
J

Jeremy Likness

@Jeremy Likness
About
Posts
38
Topics
2
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Selector (ListBox, ComboBox) default selected item woes when bound to ObservableCollection
    J Jeremy Likness

    OK, here is the scenario. Take a selector (any type of list item that you can select values) and bind it to an observable collection. Let's say that collection is populated from a service call. The issue is that you bind, the collection is empty, so there is no selected index. You cannot plug into the Loaded event on the box because if you try to set selectedindex = 0, and the collection hasn't loaded yet, you're out of luck. In the code behind I can wire into the collectionchanged and then set selectedindex = 0 but that seems a little contrived. I have a full solution using attached properties but it seems overly complicated for the behavior (I want to always default to the first item in a collection when the collection becomes available). Anyone have a similiar scenario and thoughts about a solution? One thing I looked at was having the view model raise a "collection loaded" event, but then again the view will have to hook into that in the code behind. My attached properties solution basically creates a list of weak references between the selectors and the collections, then hooks into the collection changed event. When it fires, it finds the selector it is linked to and then sets the selected index. It works like a charm but I want to make sure I'm not overcomplicating it when there may be some setting that says, "Default to the first item" when a collection gets filled. Thanks, Jeremy

    Jeremy Likness Latest Article: Silverlight Behaviors and Triggers: TextBox Magic Blog: C#er : IMage

    WPF csharp database com help question

  • Dynamic Controls not Stretching to Container Width
    J Jeremy Likness

    Worked perfectly, thank you!

    Jeremy Likness Latest Article: Decoupled ChildWindow Dialogs in Silverlight with Prism Blog: C#er : IMage

    WPF csharp css wpf wcf com

  • Dynamic Controls not Stretching to Container Width
    J Jeremy Likness

    Imagine an ItemsControl that is a fixed width. Each item is a grid with a fixed width as well. Let's say each grid item is 200 pixels wide, so when generated in the items control it's like: Name: Value Name: Value Name: Value Value is dynamically rendered. I host it inside a content control, like this:

    <ContentControl Content="{Binding Converter={ControlConverter}}" HorizontalAlignment="Stretch"/>

    Inside the converter, I might return a TextBox, a PasswordBox, a CheckBox, etc. The problem I'm having is that I am setting the width of these like so:

    return new TextBox() { HorizontalAlignment=HorizontalAlignment.Stretch };

    Of course I'm setting other properties but you get the gist. Unfortunately, the resulting controls are sizing themselves to the content, not the container. The stretch basically isn't working the same as if I have a actual TextBox in place of the content control. Anyone have an idea of why the stretch isn't working? Should I wire into some event and rebind the size somehow or make it dependent on the parent control (perhaps pass the parent as a parameter?) Thanks, Jeremy

    Jeremy Likness Latest Article: Decoupled ChildWindow Dialogs in Silverlight with Prism Blog: C#er : IMage

    WPF csharp css wpf wcf com

  • "best" Blog for text publishing ?
    J Jeremy Likness

    Anyone telling you the "best" will be giving their opinion, there is no objective winner. I use blogger.com, but wordpress.com and livejournal.com are also popular.

    Jeremy Likness Latest Article: Whats in Your Collection? Part 1 of 3: Interfaces Blog: C#er : IMage

    Web Development php business question

  • ASP
    J Jeremy Likness

    This is a great "user story" ... I went ahead and drew a use case for it: http://yuml.me/diagram/scruffy/usecase/[Database]-(RadioButton)[^]

    Jeremy Likness Latest Article: Whats in Your Collection? Part 1 of 3: Interfaces Blog: C#er : IMage

    Web Development database

  • how to bind the result of the query to the textbox in c#
    J Jeremy Likness

    Using Windows Forms controls: Beginning C# - Chapter 13: Using Windows Form Controls[^]

    Jeremy Likness Latest Article: Whats in Your Collection? Part 1 of 3: Interfaces Blog: C#er : IMage

    C# csharp database help tutorial

  • Problem in DateTime conversion!! Please help
    J Jeremy Likness

    Use SQL Parameters to Overcome Ad Hoc Performance Issues[^]

    Jeremy Likness Latest Article: Whats in Your Collection? Part 1 of 3: Interfaces Blog: C#er : IMage

    ASP.NET database help tutorial question

  • Retaining focus after postback
    J Jeremy Likness

    Why are you validating on the server when the user tabs out? I'd keep the "light" validation on the client side with JavaScript and save the postbacks for submitting the form. Then you can set the focus to the field that has errors, or move them on. That validation you are mentioning should definitely be clientside. Is the developer rolling their own code, or using something supplied by the framework like a RequiredFieldValidator that can be set to dynamic and will run on the clientside without a postback? If there is some compelling reason why you would roundtrip every time a user leaves a field (which seems to make sense only for a small internal app without many concurrent users, otherwise it won't scale well) then I'd look at using a callback instead of a postback for the validation. They are not complicated to wire in and infinitely improve the user experience while cutting down on the size of network traffic (have you used Fiddler or something similar to see how much data, like ViewState, gets thrown around when you postback?)

    Jeremy Likness Latest Article: Whats in Your Collection? Part 1 of 3: Interfaces Blog: C#er : IMage

    ASP.NET help csharp database sql-server design

  • Team Server tips?
    J Jeremy Likness

    I had a pleasant experience with it. I simply followed the walkthroughs and guidance on patterns and practices. They have several guidance articles, like: Migrating from VSS http://msdn.microsoft.com/en-us/library/ms181247(VS.80).aspx[^] Team Foundation Administration Walkthroughs http://msdn.microsoft.com/en-us/library/ms181294(VS.80).aspx[^] Then ... Branching Guidance http://www.codeplex.com/BranchingGuidance[^] We migrated several projects from VSS with a long history without issue. Our setup includes a separate build box, a proxy server in the development office and the main TFS server out in our data center. We created a special TFS Admin account registered with Active Directory and used that account for all of the connectivity, logins, etc on the proxys, build box. We were able to migrate over a weekend and have the team up, running, and productive the next week. I spent just a few hours "here and there" to slowly start to set up integration builds, script the builds to copy over to live development sites, even generate database scripts (every day when I step foot in the office, we have the most recent version of the database built along with a completely installed and configured version of the application ready for unit testing). IMHO the "power tools" are a must. I use their extensions into VS 2008 to do things like customize Work Items, etc. If you have any questions feel free to contact me but for us it was a pleasant experience. I agree if you are just looking at source control, it might seem a pain. For us, though, it was going from a clunky source control system (VSS) that caused more grief and broke more often than it worked and couldn't handle branching well to save it's life ... to a new tool that branches, merges, builds, automates test runs, tracks tickets, integrates with project plans and even serves as a Wiki and document repository for all of our design, use case, etc. Great tool when you learn how to use it to its fullest potential!

    The Lounge com sysadmin collaboration question

  • How can I prevent a user to click a button more than once
    J Jeremy Likness

    Easiest way is just to mask the button. Put a rectangle in the same container that is the width/height of the button and make it transparent. When inside grids, etc, order matters - the rectangle should be represented AFTER the button so it is in the foreground. By default, set the visibility to collapsed. When the user clicks, set it to visible until you are done initializing, then collapse it again. It will mask any clicks or UI events but not fudge the UI.

    <Grid>
    <Button/>
    <Rectangle Fill="Transparent"/>
    </StackPanel>

    Jeremy Likness
    Latest Article: Whats in Your Collection? Part 1 of 3: Interfaces
    Blog: C#er : IMage

    WPF question database

  • Fetching MAC address of clients machine
    J Jeremy Likness

    Krisha, If you are looking at the Internet, you're out of luck. TCP/IP is higher in the stack than the MAC (layer 2) and that gets lost in the router once packets are routed out to the internet. If you are looking at an Intranet, i.e. inside your 4 walls, then you'll need something native on the server that is getting the client request that can bond to and query the network adapter for the machine. That's very low-level however as the public interfaces give you the MACS of your own adapters but you really need to integrate with the router to get the MAC of the routed packets. Somewhere in the system a router maps "MAC x with IP y" and that is where you can make the translations. What's the background of what/why you need the MAC? Jeremy

    Jeremy Likness Latest Article: Whats in Your Collection? Part 1 of 3: Interfaces Blog: C#er : IMage

    ASP.NET help question

  • Connecting to Database in asp.net
    J Jeremy Likness

    You need to escape it for the slash, like this: @"Database=QD ;Server=BHUKRK83981D\SQLEXPRESS; Integrated Security = true;Connect Timeout=2000;" Or just double it up: "Database=QD ;Server=BHUKRK83981D\\SQLEXPRESS; Integrated Security = true;Connect Timeout=2000;"

    Jeremy Likness Latest Article: Whats in Your Collection? Part 1 of 3: Interfaces Blog: C#er : IMage

    ASP.NET help csharp asp-net database sysadmin

  • a simple question about design patterns [modified]
    J Jeremy Likness

    Great points! Based on what I read, it sounds like the closest pattern is really Repository. Your "EntityManagers" seem to fit the bill quite nicely.

    Jeremy Likness Latest Article: Whats in Your Collection? Part 1 of 3: Interfaces Blog: C#er : IMage

    ASP.NET database help question design data-structures

  • How to save image in a folder in silver light
    J Jeremy Likness

    You'll need to wire in a WCF service at the server side. The service would take the file information and byte array, then store it locally. In your Silverlight application, you'll reference the service, then take your image data and send it. To get to the image data, most likely you'll send it into a WriteableBitmap and then parse the Pixels array ... you can either format it on the Silverlight side and send it down, or send it raw and handle formatting on the server. Perhaps simple compression in the client, then uncompress and format into JPEG/PNG/etc on the server would be fine.

    Jeremy Likness Latest Article: Whats in Your Collection? Part 1 of 3: Interfaces Blog: C#er : IMage

    WPF sysadmin tutorial

  • How to use same usercontrol multiple time in the silverlight
    J Jeremy Likness

    Either you are instantiating the objects yourself, and can take them with x:Name and have your own reference, or you are using them in a template in the DataGrid. If you are using them in a template, you can hook into the Loaded event and do something with them. For example, you might do this:

    <DataGrid>...<u:MyControl Loaded="MyControl_Loaded".../>...</DataGrid>

    In the MyControl_Loaded you can then take the event arguments and do something with the control, either processing, passing it into a controller, etc.

    Jeremy Likness Latest Article: Whats in Your Collection? Part 1 of 3: Interfaces Blog: C#er : IMage

    WPF wpf winforms tutorial question

  • path urls relative to root of web app
    J Jeremy Likness

    For the full path use Page.ResolveUrl(), for a relative path (relative to the user's browser) use Page.ResolveClientUrl. Both will take in the ~ format and map it to a real path. If you are in a control, the methods are available from Control as well (Page is a type of Control).

    Jeremy Likness Latest Article: Whats in Your Collection? Part 1 of 3: Interfaces Blog: C#er : IMage

    ASP.NET help sysadmin security question learning

  • a simple question about design patterns [modified]
    J Jeremy Likness

    It's an interesting quesiton. First I'd ask, why do you want to know? What value will you receive in mapping patterns to your existing solution? I'm just curious, usually it's the other way around: you have a set of business requirements, then apply various patterns up front during the design process.

    Jeremy Likness Latest Article: Whats in Your Collection? Part 1 of 3: Interfaces Blog: C#er : IMage

    ASP.NET database help question design data-structures

  • Design using MVP pattern
    J Jeremy Likness

    First, why should the presentation layer work in two different presentation models? You mean the controller? I can see this: Model Controller View - one instance for web, one instance for web form That makes more sense to me. I'm also assuming your changes are to "something" not just random fields, but fields that belong to an object. So why not maintain the original object state in the controller: Controller<T> where T: class T _state; Have a typed args, something like: public class TypedArgs<T> : EventArgs where T: class { public T Value { get; set; } } Create an interface for your views: public interface IView<T> where T: class { event EventHandler<TypedArgs<T>> Changed; } then you can raise Changed with the new entity in the view, and have the controller register. Just pass in IView to the controller so it doesn't care if it's a user control or a web form, and when Changed is raised, it can compare e.Value to the stored state and decide what to do.

    Jeremy Likness Latest Article: Hierarchal Data Templates in Silverlight Blog: C#er : IMage

    ASP.NET design regex architecture question announcement

  • Security tree structure
    J Jeremy Likness

    Right ... haven't looked in to the 2008 solution but in 2005 it's as simple as: ID SecurityName ParentID Then you can use hierarchal queries (recursive CTE or common table expressions) to unroll the tree. Example: http://www.eggheadcafe.com/articles/sql_server_recursion_with_clause.asp[^]

    Jeremy Likness Latest Article: Hierarchal Data Templates in Silverlight Blog: C#er : IMage

    Database sharepoint data-structures security question

  • Silverlight webservice
    J Jeremy Likness

    We have a similar issue where we have a large block of data that displays on a dashboard. It can be accessed by 1..N clients and involves some complex queries and therefore we don't want to be re-running it each time the request is made. The solution is to cache on the server side. There are several ways to tackle this. I would start by abstracting your service with an interface (should be doing this already) and then having the interface also receive a cache interface, ICache. You can make it simple, for example, perhaps you construct it with a factory like this: ICache cache = CacheFactory.RetrieveCache(TimeSpan lifespan); This gives you flexibility for how long it is cached. Then, you might use the ASP.NET Web Cache - take a look here for some exhaustive examples/solutions: Exploring Caching in ASP.NET[^] Another option is to use the Singleton pattern and create a static class with a "lastcached" date and the parsed file. Basically, you expose a method "getparsedfile" and the method checks the lastcached. If it was cached less than you interval, it will simply return the cached object, otherwise it locks the object, updates the date and then re-parses the file. Hope that makes sense!

    Jeremy Likness Latest Article: Hierarchal Data Templates in Silverlight Blog: http://csharperimage.jeremylikness.com/

    Web Development question csharp wcf game-dev json
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups