Yet another coding blog covering everything from C#, WPF, SQL, and Silverlight to any other random thought that passes my way…
RSS icon Home icon
  • New Project – Seesmic Plugin Video Preview (view Youtube and Twitvid videos in Seesmic)

    Posted on June 20th, 2010 biggert 5 comments

    So I just completed my second plugin for Seesmic Desktop. The Video Preview plugin allows the user to view Youtube and Twitvid videos where links are posted without leaving Seesmic. Now, there’s a preview thumbnail of the video shown at the bottom of the post in the timeline and, which the user clicks it, a dialog will be show allowing the user to view the video. You can read more details here about the plugin or just dive in and download it here.

    Let me know if y’all have any problems with it!

  • WPF Datagrid and the dreaded double-tab focus issue

    Posted on November 24th, 2009 biggert 5 comments

    So I just had to figure this out on my own over the last hour or so and found it to be a good candidate for a post. I found my path through the internet on this one but apparently everyone’s solution didn’t exactly equal to mine for some reason or another. So here we go:

    Problem:

    When using a DataGridTemplateColumn from the DataGrid in the WPF Toolkit in .NET 3.5 (after attending PDC09, I know .NET4 will have a built-in WPF DataGrid), if you want to simply use tab to change the focus between controls within the cells, you’ll have to double-tab to move to the next control.

    For example, if I have a textbox in a cell and want to move to a textbox in another cell within the datagrid with TAB, hitting TAB once will move me to the next DataGridCell… then I have to press TAB again to move to the TextBox inside that DataGridCell.

    Solution:

    After googling around, I frequently hit this site which supposedly fixed this problem with a nice little solution: http://blog.yalovoi.net/2009/08/21/

    For some reason unknown to me and not worth my time to investigate, it doesn’t work at all. Here’s what I came up with which is uglier but, in my case, works. I simply navigate the tree from the DataGrid to the textbox.

    Forgive my quick and dirty coding but it gets the job done… I’m sure you could easily spawn a much more generic code to do this:

            private void uxFieldMappingsDataGrid_CurrentCellChanged(object sender, EventArgs e)
            {
                uxFieldMappingsDataGrid.BeginEdit();
            }
    
            private void uxFieldMappingsDataGrid_PreparingCellForEdit(object sender, DataGridPreparingCellForEditEventArgs e)
            {
                ContentPresenter cp = (ContentPresenter)e.EditingElement;
    
                TextBox destinationTextBox = VisualTreeHelper.GetChild(cp, 0) as TextBox;
    
                if (destinationTextBox != null && destinationTextBox.Name == "uxTest")
                {
                    destinationTextBox.Focus();
                }
            }
    

    You can see where I climb the visual tree down to the text box. Very simple code for a very specific reason that I’m sure you can mold to make your own if you find that you are having the same problems as I am (and using code-behind to solve it isn’t against your religion).

  • Can’t figure out how to implement a custom IDataReader to my collection

    Posted on October 22nd, 2009 biggert No comments

    I hope someone can help me here… I’ve been working on this for 4 days now with barely any luck.

    Here’s the question:

    I know it is possible to create a custom datareader (inferring from the IDataReader interface) which accesses the data in a collection. I’ve seen it used in other third-party controls and am wanting to do it myself. I’ve come across an ancient (2004) website of how a guy explains how to do it (http://blogs.msdn.com/yvesdolc/archive/2004/11/08/254209.aspx) but I am having difficulty implementing his code since he did not provide examples and 2004 C#/.NET2.0 might not be as performance-tuned as the latest and great C#/.NET3.5. Can anyone assist me in either providing some samples on how to do this or providing some sources that can teach me how to do this. I’m googled up and down on a tutorial on how to write a custom datareader but everything I find isn’t very helpful… it either lists code that’s already complete without good information of how they got there or has code that doesn’t do what I need it to do.

    Just to make it easy, I’ve included an example collection in the code so that, if examples are provided, they can reference it.

    NOTE: Just an additional item, if this can be generic-ized in a way to support different types of collections, that’s a huge plus!

    public class Person
    {
         public int ID {get; set;}
    
         public string Name {get; set;}
    
         public string Gender {get; set;}
    
         public Person()
         {
    
         }
    
         public Person (int id, string name, string gender)
         {
    
              ID = id;
              Name = name;
              Gender= gender;
         }
    }
    
    public class People : List
    {
         public People { };
    }
    
    public void Main()
    {
         Person person1 = new Person(1, "John Doe", "Male");
         Person person2 = new Person(2, "Jane Smith", "Female");
         Person person3 = new Person(3, "Tom White", "Male");
    
         People peeps = new People();
    
         peeps.Add(person1);
         peeps.Add(person2);
         peeps.Add(person3);
    
    }
    

    UPDATE (10/29/2009): Well, I figured out a way to get his code and it was well worth the effort as I noticed an increase in performance (as well as a significant decrease in MEM usage) when using his datareader over converting to a datatable. I’m busy coding away at it and I having yet figured out how to keep it as generic as I’d like but his code works well for now. I’ll post the solution (using his code) at a later date so everyone can see. It’s actually quite simple….