<StackPanel >
<TextBlock Text="{Binding ElementName=btn,Path=Foreground.Color.R}">
</TextBlock>
<Button Foreground="Red" Name="btn"/>
</StackPanel>
Friday, April 20, 2007
Get the template of 3rd party controls
If we dont have template of a Control we could get that using Blend.
Load the control in Blend and right click on it then select
Edit Control Parts(Template) -> Edit a Copy
This will create a copy of the template in xaml file.
Load the control in Blend and right click on it then select
Edit Control Parts(Template) -> Edit a Copy
This will create a copy of the template in xaml file.
Vista theme support in XP using WPF
This wont change the look and feel of the Window as in Vista ie the transparent window title.But changes the look and feel of the elements (Button,Combo etc) inside that Window.
http://blogs.msdn.com/llobo/archive/2006/12/13/Vista-look-on-Non_2D00_Aero-themes.aspx
http://blogs.msdn.com/llobo/archive/2006/12/13/Vista-look-on-Non_2D00_Aero-themes.aspx
Know the state of a object in XAML format at runtime
The below code gives the XAML representation of object at runtime.
MessageBox.Show(System.Windows.Markup.XamlWriter.Save(sp));
Using this we can save the current state of the objects..
MessageBox.Show(System.Windows.Markup.XamlWriter.Save(sp));
Using this we can save the current state of the objects..
Creating a control from xaml string at runtime
string s = "< Button xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation' xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml' >";
s += "Hai";
s += " < /Button > ";
Stream strm = new MemoryStream(ASCIIEncoding.Default.GetBytes(s));
Button b = (Button)System.Windows.Markup.XamlReader.Load(strm);
stackPanel.Children.Add(B);
s += "Hai";
s += " < /Button > ";
Stream strm = new MemoryStream(ASCIIEncoding.Default.GetBytes(s));
Button b = (Button)System.Windows.Markup.XamlReader.Load(strm);
stackPanel.Children.Add(B);
How can we make a TextBox looks like Button using template?
If we wanna make the Button looks like TextBox it is easy,just add the TextBox as content of Button.But the reverse is not possible sice TextBox doesnt have Content property.So use Templating.
< TextBox Text="Hai" >
< TextBox.Template >
< ControlTemplate >
< Button Content="hai"/ >
< /ControlTemplate >
< /TextBox.Template >
< /TextBox >
CS Code
ControlTemplate ct=new ControlTemplate(typeof(TextBox));
FrameworkElementFactory fef=new FrameworkElementFactory(typeof(Button));
fef.SetValue(Button.ContentProperty,"hai");
ct.VisualTree =fef;
txt.Template = ct;
< TextBox Text="Hai" >
< TextBox.Template >
< ControlTemplate >
< Button Content="hai"/ >
< /ControlTemplate >
< /TextBox.Template >
< /TextBox >
CS Code
ControlTemplate ct=new ControlTemplate(typeof(TextBox));
FrameworkElementFactory fef=new FrameworkElementFactory(typeof(Button));
fef.SetValue(Button.ContentProperty,"hai");
ct.VisualTree =fef;
txt.Template = ct;
Thursday, April 19, 2007
Access yahoo through XAML in WPF
See this and know how to access the information on yahoo through XPath
http://developer.yahoo.com/dotnet/howto-wpf_xaml.html
http://developer.yahoo.com/dotnet/howto-wpf_xaml.html
Start WPF 3D here
This helps us to understand what is Mesh,Normals etc and finally make us capable of creating a cube
http://www.kindohm.com/technical/WPF3DTutorial.htm
http://www.kindohm.com/technical/WPF3DTutorial.htm
Some WPF tutorial sites
WPF tutorials
http://www.wpftutorial.net/
http://www.airknow.com/Tutorials/WPF/WPFTutorials.aspx
http://aspalliance.com/706
http://www.codeproject.com/wpf/
http://geekswithblogs.net/bander/archive/2006/01/25/67026.aspx
http://learnwpf.com/
http://thewpfblog.com/
http://wpf.netfx3.com/
http://channel9.msdn.com/tags/WinFX
http://wpfxaml.spaces.live.com/
http://www.windowspresentationfoundation.com/
Cheat sheets
WPF XAML Data Binding Cheat Sheet (PDF), latest version, updated February 2
XAML for WPF Cheat Sheet 1.0
http://www.wpftutorial.net/
http://www.airknow.com/Tutorials/WPF/WPFTutorials.aspx
http://aspalliance.com/706
http://www.codeproject.com/wpf/
http://geekswithblogs.net/bander/archive/2006/01/25/67026.aspx
http://learnwpf.com/
http://thewpfblog.com/
http://wpf.netfx3.com/
http://channel9.msdn.com/tags/WinFX
http://wpfxaml.spaces.live.com/
http://www.windowspresentationfoundation.com/
Cheat sheets
WPF XAML Data Binding Cheat Sheet (PDF), latest version, updated February 2
XAML for WPF Cheat Sheet 1.0
WPF 2D controls in 3D viewport
Get the library from below link which helps us to include 2d controls like Button,Textbox etc into 3D viewport.
http://codeplex.com/3DTools
Also this will raise all the events such as Click,MouseDown of 2D controls.
http://codeplex.com/3DTools
Also this will raise all the events such as Click,MouseDown of 2D controls.
New confusing things in WPF
DependencyObject and DependencyProperty
Logical and VisualTree
Tunnel and Bubble events
XBAP and Standalone applications
XBAP and WPF/E
ControlTemplate and DataTemplate
Style and Template
Need to complete
Command and Event
Window and Page
Static and Dynamic resources
Logical and VisualTree
Tunnel and Bubble events
XBAP and Standalone applications
XBAP and WPF/E
ControlTemplate and DataTemplate
Style and Template
Need to complete
Command and Event
Window and Page
Static and Dynamic resources
Applying same style to all wpf elements of same type
The folloging code will give a Red background to all the Buttons in the Window provided if we didnt set the ButtonBackground explicitly
< Window.Resources >
< Style x:key="{x:Type Button}" TargeType="{x:Type Button}" >
< Setter Property ="Background" Value ="Red"/ >
< /Style >
< /Window.Resources >
C# Code
Style sty = new Style(typeof(Button));
Setter set = new Setter(Button.BackgroundProperty , Brushes.Red);
sty.Setters.Add(set);
Resources.Add(typeof( Button), sty);
Welcome
Sharing My WPF experiences....
The posts will contain links more which are useful than my own articles :-)
The posts will contain links more which are useful than my own articles :-)
Subscribe to:
Posts (Atom)