|
You can use
XamlReader.Load() .
Hope it helps.
Thanks and Regards,
Michael Sync ( Blog: http://michaelsync.net)
Microsoft MVP (Silverlight), WPF/Silverlight Insiders
|
|
|
|
|
We have a number of button images used in our app. As expected, management isn't sure that it's happy with the current images, so I am trying to come up with several different sets that can easily be swapped into the application. What's the best way to go about doing this? Is "use themes" the answer? If so, can someone steer me to relevant discussions/examples?
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
I'm not sure how theming work, never did it myself.
Although this codeplex library can help perhaps?
http://wpfthemes.codeplex.com/[^]
In my case I use object template in the App resource if I want to change the look of the object.
But your case is a it different.
You don't specially want to change the look of button in general (or so it seems) but of individual button in particular...
Maybe their image content or whatever could be:
<Button Content="{StaticResource buttonFooContent}">
And then in you app resource you can define
<SomeUI x:Key="buttonFooContent" x:Shared="true" />
and you can change the content anytime in the App resource file and everyone will get it!
How about that?!
A train station is where the train stops. A bus station is where the bus stops. On my desk, I have a work station....
_________________________________________________________
My programs never have bugs, they just develop random features.
|
|
|
|
|
This[^] article isn't a bad start.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Hey all
Im new to silverlight, just want to know how to embed or add silverlight to an existing ASP.net project. In flash you only use the following code:
<object width="871px" height="400px">
<param name="aa" value="aa.swf" />
<embed src="flash\aa.swf" width="871px" height="400px"></embed>
</object>
Can someone tell me how do it with Silverlight.
Thanx
|
|
|
|
|
|
|
Hi,
I have a few vector images in XAML format that I'd like to display in my application. So far I've been able to do this using:
private XmlReader reader_;
private UIElement control_;
...
reader_ = XmlReader.Create(filename_);
control_ = (UIElement)XamlReader.Load(reader_);
Then having a Control property:
public UIElement Control
{
get
{
return control_;
}
}
And binding to this as below:
<DataTemplate DataType="{x:Type local:Tile}">
...
<Viewbox>
<Label Content="{Binding Control}" />
</Viewbox>
...
This works, but when I try and display the control in multiple controls in the same window, only one will appear. I was able to fix it by doing this:
public UIElement Control
{
get
{
XmlReader reader = XmlReader.Create(filename_);
return (UIElement)XamlReader.Load(reader);
}
}
But I'd really like to avoid parsing the XAML and reloading the control every time I use it! This is my first WPF project. Can someone recommend a better way of doing this?
Cheers!
Jack
|
|
|
|
|
I define my vector images as resources, then create controls which point to that resource for their background property, from memory.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
I'm just looking into using WPF and have a simple problem.
I just want to style a treeview control, but when I add the styling to my resource dictionary, I get error :
"The attached property 'Window.Resources' is not defined on 'ResourceDictionary' or one of its base classes."
The xml is :
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Window.Resources>
<Style TargetType="{x:Type TreeViewItem}">
..........
</Style>
</Window.Resources>
</ResourceDictionary>
|
|
|
|
|
Window.Resources is needed to define a resource in your Window XAML (in the same way as UserControl.Resources is used in a UserControl, and so on). You don't need this in a resource dictionary, so you need to remove the lines
:<Window.Resources> and
</Window.Resources>
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
|
vidster wrote: I have defined the resourcedictionary in the Application XAML, so it should work?
That's right. Just remember that it's an application resource, so you don't have to wrap it in a container Resources section such as a Window.Resources.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Yes, but I'm not setting the style in the Application XAML, I just want to point it to my resource dictionary (Styles.XAML) :
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Styles.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
|
|
|
|
|
I think you misunderstand me. Because you have created this in a ResourceDictionary , you don't need the Window.Resources part - that's what I mean by application resources. The way you are merging your resource dictionary in is spot on.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Ah..ok, thanks.
i guess the tutorial I referenced is incorrect.
|
|
|
|
|
Hi,
I'm looking for good online tutorials for C# for beginners. If it matters I want to use it with WPF.
Thanks.
modified on Thursday, July 30, 2009 4:18 PM
|
|
|
|
|
You're looking for tutorials that teach you WPF ? Why don't you just buy a good book ?
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Thanks for the reply. Being new to programming I'm here to ask experienced programmers what is good and what isn't.
|
|
|
|
|
Hi Copec,
"Being new to programming I'm here to ask experienced programmers what is good and what isn't."
I think you'll find a lot of great WPF tutorials and articles here on CodeProject in the writings of Sasha Barber, Marc Clifton (the man on XAML), Josh Smith, Pete O'Hanlon, and others : please look them up.
While I am experienced as a programmer in C# and WinForms, I am very new to WPF : so I can only tell you what I have heard from someone who is very "deep" into WPF, and what I am finding valuable to me as I am plunging in to learning it myself. So you are warned
A very talented WPF programmer I recently met who has published a well-received article here on WPF on CodeProject recently recommended Adam Nathan's book :
Windows Presentation Foundation Unleashed (Sams, 2007)
to me, and I am finding it very valuable. Nathan is a senior software developer at MS, and his co-author was a lead developer on 3d for WPF (is Nathan still at MS ? Don't know : his blog is just a bunch of ads for his books).
I am also reading Matthew McDonald's book on WPF :
Pro WPF in C-Sharp 2008 - Windows Presentation Foundation with .NET 3.5, Second Edition; Matthew MacDonald (Apress, 2008)
I have a very high opinion of every book of McDonald's I've read : I think his book :
Pro .NET 2.0 Windows Forms and Custom Controls in C# (APress 2008) on WinForms and UserControls is superb.
In terms of C# itself, independent of WinForms and WPF, I personally think Jessie Liberty's books for O'Reilly are the best including :
Programming C# 3.0 (O'Reilly 2008)
Visual C# 2005: A Developer's Notebook (O'Reilly 2005)
... edit ... and, I forgot to say Andrew Troelsen's latest :
Pro C# 2008 and the .NET 3.5 Platform, Fourth Edition
Is the best I know of for "language theory."
Good luck, Bill
"Many : not conversant with mathematical studies, imagine that because it [the Analytical Engine] is to give results in numerical notation, its processes must consequently be arithmetical, numerical, rather than algebraical and analytical. This is an error. The engine can arrange and combine numerical quantities as if they were letters or any other general symbols; and it fact it might bring out its results in algebraical notation, were provisions made accordingly." Ada, Countess Lovelace, 1844
|
|
|
|
|
Hi All,
In a WPF UI Application, I have 4 controls and 3 radio buttons( say write, read and load). I have aligned them Properly too.
4 controls are : 1. Tabcontrol with listview in it 2. Stackpanel with checkboxes 3. Stackpanel(orientation - Horizantal) with textbox and browse button 4. A stackpanel with Textblock and Listview.
My question is, for Load RadioButton, I should have all the 4 controls stacked vertically. (this is no issue, its done.. )
for Write button, the controls 2 and 3 should be invisible and the control 1 and 4 should fill tht area.
ctrl ht
1 150
2 100
3 30
4 200
When i press write, the ctrl 2 n 3 shuld become invisible and the ctrl 1 height should be (150 + 75) and ctrl 4 should be (200 + 55).. which makes ctrl1 lower limit should move down to 75 pixels and ctrl 4 upper limit should be 55 pixels above..
please help me in doing this.. I am using XAML and C# for this WPF app
thanks Ramm
|
|
|
|
|
If you want to change the heights, you probably need to do that manually. I would imagine if you had the pairs of controls inside a single control of the combined height, and had the control you don't hide set to fill the available area, then the other control would limit it, or not, depending on if it is collapsed or not. But as you want to hide a control that is 100 high and replace it with 75 pixels of space, you'll need to do something more direct and manual.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Ok, I appreciate the strong data orientated design of Silverlight (WPF) and the power of Binding etc, but after all it is UI technology...
The omission of even basic UI support really baffles me, simple things like:
- looping over controls, did they assume my data object is going to represent all the attributes of my presentation layer? (Try setting custom values for the GroupName of radio buttons after using Binding to generate them)
- the TreeView's SelectedItem attribute gives you the data object bound to the Tree Node that is selected, how do I get (or set) the selected Node? And I need to get the parent Node of the selected Node?
Did Microsoft assume that we wouldn't need to do these things, or didn't they have enough time to include them (were they more intent on selling than building?) I understand Silverlight is a compact framework and that they had to omit certain things, but to omit basic UI functionality from a UI framework???
____________________________________________________________
Be brave little warrior, be VERY brave
|
|
|
|
|
Adriaan Davel wrote: looping over controls, did they assume my data object is going to represent all the attributes of my presentation layer?
It's still present - you use the VisualTreeHelper class to iterate over the controls.
Adriaan Davel wrote: the TreeView's SelectedItem attribute gives you the data object bound to the Tree Node that is selected, how do I get (or set) the selected Node? And I need to get the parent Node of the selected Node?
Have a read of this[^] thread.
Adriaan Davel wrote: I understand Silverlight is a compact framework and that they had to omit certain things, but to omit basic UI functionality from a UI framework
That's not the case - you need to learn the new way of doing things that is behind Silverlight and WPF. You can't really use the same techniques you used in WinForms/ASP.NET; it's a totally different way of working. Once you get your head round it, it makes a lot of sense - and is actually very, very powerful.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Pete O'Hanlon wrote: It's still present - you use the VisualTreeHelper class to iterate over the controls.
Sure, but why need another class to iterate over a collection (surely there is a collection that holds the controls)? Now I need to get the .Count and then for over it, like languages from the olden days... Why can't I LINQ to get controls etc...
Pete O'Hanlon wrote: Have a read of this[^] thread.
Read it, VERY messy code to achive very simple functionality...
Pete O'Hanlon wrote: really use the same techniques you used in WinForms/ASP.NET;
The fact of the matter is that the functional requirements are the same, but the technical ability to fulfill the requirements has been stripped and now needs lots of work arounds and looping...
Pete O'Hanlon wrote: and is actually very powerful
I agree, if you do things the way that they work, if you need something slightly different, you have no power at all and need to loop and hack...
I don't mean to be negative, but I am very disappointed...
____________________________________________________________
Be brave little warrior, be VERY brave
|
|
|
|