|
Hi,
I am working on WPF controls, I have a halt at adjusting one of the controls programatically.
I have 2 radiobuttons (rdbtn1, rdbtn2) and a dockpanel(2 controls) with a stackpanel(with textbox and button)a another stackpanel(with 2 textboxes).
so the panels are placed at (40,10,0,0) and (40,150,0,0) with panel1 above and panel2 below it.
actually the problem is selecting one of radiobuttons .
if i select rdbtn2, the panel1 shuld be invisible and the panel2 should stretch (not shift, which mean if the panel2 height is 200 and it should stretch its starting point in vertical to 10 and its lower limit should be same , making total height of 140 + 200 )to the panel1 starting location .
so, only panel2 shuld be visible. how to do this programatically in C#?
Please help..
Thank you,
Ramm
|
|
|
|
|
I would put them in a stackpanel or a grid, and try to set them up so their size is determined by the available space, so that when you collapse one, the other would fill the space.
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.
|
|
|
|
|
Okay, I found out what's eating my (non-keyed) global style. I had this in my app.xaml (my global textbox style is in Styles.xaml):
<ResourceDictionary Source="/PresentationFramework.Aero;V3.0.0.0;31bf3856ad364e35;component/themes/aero.normalcolor.xaml" >
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/WpfTest;component/Dictionaries/Resources.xaml" />
<ResourceDictionary Source="/WpfTest;component/Dictionaries/Styles.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
When I changed it to this, all of a sudden my style started to work as expected:
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/WpfTest;component/Dictionaries/Resources.xaml" />
<ResourceDictionary Source="/WpfTest;component/Dictionaries/Styles.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
0) Why does this work like this? Is it a bug or "as designed"?
1) The reason I was adding the aero.normalcolor resource dictionary was to force XP to use the aero theme. How do I force the aero look and still be able to use my own global style overrides? Can I do this and get the same results?
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/PresentationFramework.Aero;V3.0.0.0;31bf3856ad364e35;component/themes/aero.normalcolor.xaml" />
<ResourceDictionary Source="/WpfTest;component/Dictionaries/Resources.xaml" />
<ResourceDictionary Source="/WpfTest;component/Dictionaries/Styles.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
"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
|
|
|
|
|
Sadly, I found out that SL 3 doesn't support the FlowDocument.
I need to load a xaml file from the server into the client browser. No problem doing that using the webservice. The problem is how to display the file in a page and allow for printing.
NOTE: The xaml file is actually a simple table having 2 columns and several rows with simple text attributes
|
|
|
|
|
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
|
|
|
|