Wednesday, March 4, 2015

Microsoft Surface Hub (new large screen multitouch device that runs Windows 10)

http://www.microsoft.com/microsoft-surface-hub/en-us http://www.theverge.com/2015/1/21/7863319/microsoft-surface-hub-action-video

Thursday, April 14, 2011

MultiSelect ListBox in Silverlight - Use SelectedItems Behavior

I have used the existing SelectedItems Behavior by added following features.
- Show the selected items, when collection rebinded
- Update selected items when collection Changed


public static class SelectedItems
{
private static readonly DependencyProperty SelectedItemsBehaviorProperty =
DependencyProperty.RegisterAttached(
"SelectedItemsBehavior",
typeof(SelectedItemsBehavior),
typeof(ListBox),
null);

public static readonly DependencyProperty ItemsProperty = DependencyProperty.RegisterAttached(
"Items",
typeof(IList),
typeof(SelectedItems),
new PropertyMetadata(null, ItemsPropertyChanged));

public static void SetItems(ListBox listBox, IList list)
{ listBox.SetValue(ItemsProperty, list); }
public static IList GetItems(ListBox listBox)
{ return listBox.GetValue(ItemsProperty) as IList; }

private static void ItemsPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var target = d as ListBox;
if (target != null && e.NewValue != null)
{
SelectedItemsBehavior itemsBehavior = GetOrCreateBehavior(target, e.NewValue as IList);
itemsBehavior.RemoveSelectionChangedHandler();
target.SelectedItems.Clear();
foreach (var item in e.NewValue as IList)
{
target.SelectedItems.Add(item);
}
itemsBehavior.AddSelectionChangedHandler();
}
}

private static SelectedItemsBehavior GetOrCreateBehavior(ListBox target, IList list)
{
var behavior = target.GetValue(SelectedItemsBehaviorProperty) as SelectedItemsBehavior;
if (behavior == null)
{
behavior = new SelectedItemsBehavior(target, list);
target.SetValue(SelectedItemsBehaviorProperty, behavior);
}
else
{
behavior.SetNewList(list);
}

return behavior;
}
}

public class SelectedItemsBehavior
{
private readonly ListBox _listBox;
private IList _boundList;

public SelectedItemsBehavior(ListBox listBox, IList boundList)
{
_boundList = boundList;
_listBox = listBox;
_listBox.Loaded += new RoutedEventHandler(_listBox_Loaded);
AddCollectionChangedHandler();

}

void SelectedItemsBehavior_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
{
RemoveSelectionChangedHandler();
_listBox.SelectedItems.Clear();
foreach (var item in _boundList)
{
_listBox.SelectedItems.Add(item);
}
AddSelectionChangedHandler();
}

void _listBox_Loaded(object sender, RoutedEventArgs e)
{
foreach (var item in _boundList)
{
_listBox.SelectedItems.Add(item);
}
}

private void OnSelectionChanged(object sender, SelectionChangedEventArgs e)
{
RemoveCollectionChangedHandler();
_boundList.Clear();

foreach (var item in _listBox.SelectedItems)
{
_boundList.Add(item);
}
AddCollectionChangedHandler();
}

public void SetNewList(IList boundList)
{
RemoveCollectionChangedHandler();
_boundList = boundList;
AddCollectionChangedHandler();
}

public void AddSelectionChangedHandler()
{
_listBox.SelectionChanged += OnSelectionChanged;
}

public void RemoveSelectionChangedHandler()
{
_listBox.SelectionChanged -= OnSelectionChanged;
}

public void AddCollectionChangedHandler()
{
if (_boundList == null) return;
(_boundList as INotifyCollectionChanged).CollectionChanged += new NotifyCollectionChangedEventHandler(SelectedItemsBehavior_CollectionChanged);
}

public void RemoveCollectionChangedHandler()
{
if (_boundList == null) return;
(_boundList as INotifyCollectionChanged).CollectionChanged -= new NotifyCollectionChangedEventHandler(SelectedItemsBehavior_CollectionChanged);
}

}

Monday, February 21, 2011

RIA Resource File link issue: could not find any resources appropriate for the specified culture or the neutral culture.

RIA adding Resource file link to the SL project. (http://forums.silverlight.net/forums/p/184013/493474.aspx )

<EmbeddedResource Include="..\ServerCoreLibrary\Resources\GroupResource.resx">
<Link>Resources\GroupResource.resx</Link>
<LogicalName>ServerCoreLibrary.Resources.GroupResource.resources</LogicalName> <Generator>PublicResXFileCodeGenerator</Generator>
<LastGenOutput>GroupResource.Designer.cs</LastGenOutput>
</EmbeddedResource>

Database diagram support objects cannot be installed because this database does not have a valid owner

In SQL 2005, if you get this message when trying to create a new Database Diagram:

"Database diagram support objects cannot be installed because this database does not have a valid owner. To continue, first use the Files page of the Database Properties dialog box or the ALTER AUTHORIZATION statement to set the database owner to a valid login, then add the database diagram support objects."

Here are the sql statements to resolve this:

EXEC sp_dbcmptlevel 'yourdatabasename', '90';
go
ALTER AUTHORIZATION ON DATABASE::yourdatabasename TO "dbusername"
go
use [yourdatabasename]
go
EXECUTE AS USER = N'dbo' REVERT
go

Friday, March 19, 2010

Check another user TFS checkouts

Open Visual studio Command prompt

tf status $/[ProjectName] /user:[username] /s:[TFS Server URL]:[port] /recursive