ObjectDataProvider - Wraps and creates an object that you can use as a binding source. Allows binding to objects that do not have a default constructor and that can be called Asynchronously.
http://www.thomasclaudiushuber.com/blog/2008/01/10/bind-to-methods-with-objectdataprovider/ - Nice simple example of using ObjectDataProvider
February 16, 2012
Data Templates
Taken from Top Ten UI Development Breakthroughs In Windows Presentation Foundation
You don't have to set the data template on a particular control. If you prefer, you can associate a data template with a particular type, indicating that WPF should use the specified template whenever it encounters that particular type as content.
eg
You don't have to set the data template on a particular control. If you prefer, you can associate a data template with a particular type, indicating that WPF should use the specified template whenever it encounters that particular type as content.
eg
<Window.Resources>
<DataTemplate DataType="{x:Type local:Person}"> <StackPanel Orientation="Horizontal"> <TextBlock FontWeight="Bold">Name:</TextBlock>
<TextBlock Text="{Binding Name}" Margin="2,0,10,0" /> <TextBlock FontWeight="Bold">
Date of birth:</TextBlock> <TextBlock Text="{Binding DateOfBirth}"Margin="2,0,10,0" /> </StackPanel> </DataTemplate>
</Window.Resources>
Anything in the window that uses a Person object as its content will pick up this data template by default. Example C++/CLI sealed properties and methods
This is to help remember the syntax of this stuff, it is too easy to forget
Or split into source and header
Header file:
virtual void EnableStuff() sealed = IStuffEnabler::EnableStuff
{
stuffEnableImpl();
}
virtual property bool IsStuffEnabled
{
bool get() sealed = IStuffEnabler::IsStuffEnabled::get
{
return stuffIsEnabledImpl();
}
}
Or split into source and header
Header file:
virtual void EnableStuff() sealed = IStuffEnabler::EnableStuff;
virtual property bool IsStuffEnabled
{
bool get() sealed = IStuffEnabler::IsStuffEnabled::get;
}
and source file:void StuffEnabler::EnableStuff()
{
stuffEnableImpl();
}
bool StuffEnabler::IsStuffEnabled::get()
{
return stuffIsEnabledImpl();
}
January 26, 2012
Lazy<T>
Added in version 4.0 of .Net, a lazy template. The concept of 'Lazy' programming is quite simple, do not create an object until you actually use it. Lazy has 2 properties, "IsValueCreated" and "Value". "IsValueCreated" specifies if the templated object has been created yet or not whilst "Value" when invoked actually creates an instance of the templated item.
Here is a simple example:
. Fortuneately, NInject works with Lazy<> parameters. This is a sneaky way to implement late binding. I used this in a recent project to late bind some IPlugin interfaces. Some plugins were injected into a constructor as Lazy plugins. This means that when the constructor was invoked the plugins were not created immediately. It is only when the "plugins.Value" parameter is accessed that NInject actually constructed the plugins. In this case this did not happen in the constructor at all, it is invoked later in another separate "Initialise" method.
Here is a simple example:
public class Thingey
{
public string Name { get; set; }
}
To test it:internal void TestLazyTemplate()
{
Lazy<Thingey> myThingey = new Lazy<Thingey>();
bool isCreated = myThingey.IsValueCreated;
Debug.Assert(isCreated == false); // Not created yet
myThingey.Value.Name = "Sutum"; // Created when accessed
isCreated = myThingey.IsValueCreated;
Debug.Assert(isCreated == true);
}
This is a simple example but does not really show the power of LazyOctober 20, 2011
gcroot and pin_ptr
Reference managed type members in an unmanaged class by using the "gcroot<>" template. This provides a wrapper around the GCHandle class.
Look at this msdn explanantion
Also there is this article on codeproject
Look at this msdn explanantion
Also there is this article on codeproject
gcrootPinning in C++/CLI. Do this using the pin_ptr keyword. This prevents the managed object from being moved around in memory by the garbage collectorstr; str = gcnew String("hello");
Object ^obj = gcnew MyClass(); pin_ptr pinned = obj;
October 12, 2011
CSS Positioning Concepts
CSS unit of measurement 1ex= width of letter "x"
CSS Positioning Concepts
CSS Positioning
Positioning in 10 easy steps with pictures - very good
“position:relative”
The “position:relative” is best used when you want to adjust some element's position slightly. The “relative” means it is relative to the parent tag's rendering box. More here
"position:fixed"
Position is fixed to the browser window. For example "<div style="position:fixed; right:1ex; bottom:1ex">" fixes to the bottom right hand corner of the browser window. More from the original source
When a element is “position:fixed”, it is moved into a layer by itself. Use the "z-index" parameter to specify if it is on top or below the over elements. Again, more here
CSS Positioning Concepts
CSS Positioning
Positioning in 10 easy steps with pictures - very good
“position:relative”
The “position:relative” is best used when you want to adjust some element's position slightly. The “relative” means it is relative to the parent tag's rendering box. More here
"position:fixed"
Position is fixed to the browser window. For example "<div style="position:fixed; right:1ex; bottom:1ex">" fixes to the bottom right hand corner of the browser window. More from the original source
When a element is “position:fixed”, it is moved into a layer by itself. Use the "z-index" parameter to specify if it is on top or below the over elements. Again, more here
October 6, 2011
Printing HTML
To initiate the Print of a web page use the following HTML and Javascript:
There is more on this at Htmlgoodies
<a href="javascript:window.print()">Print Page</a>This is how the link looks: Print Page
There is more on this at Htmlgoodies
Subscribe to:
Posts (Atom)