|
|
Hey guys,
I'm creating a control in blend and I'm having some trouble understanding how I would accomplish a certain task.
The idea is I put a textblock on a form and then during runtime, this textblock's text must change based upon 4 different buttons that are pushed within the same control.
The problem is, I'm new to WPF and Blend - and I am unsure if this is possible.
The only alternative is I add a label in place of the textblock and change that text programatically(using visual studio code) - is this the preferred method or is there a way to bind the textblock.text to one of the selected buttons and have it change dynamically upon the selected button?
Thanks in advance,
Smithy.
|
|
|
|
|
In some way shape or form you will have to do some code behind (visual studio) in order to accomplish what you want. I do not believe it is possible for one xaml property to be binded to one of 4 different xaml controls. You will have to add some logic in order to accomplish what you want.
Regards,
Thomas Stockwell
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
Visit my Blog
|
|
|
|
|
Hi all,
I am trying to practice and create a simple data template for a simple class I wrote.
CLR:
public class Customer
{
public string CustomerName
{
get { return mCustomerName; }
set { mCustomerName = value; }
}
public List<string> RentedBooks
{
get { return mRentedBooks; }
set { mRentedBooks = value; }
}
public string mCustomerName;
public List<string> mRentedBooks;
}
</string></string>
My Questions:
1. Do I have to create a property for CustomerName? I didn't get it to work with a public member, only with an explicit property declaration.
2. How do I get the list of strings to be displayed using a listbox?
Thanks all...
|
|
|
|
|
pym wrote: 1. Do I have to create a property for CustomerName?
Yes[^]
pym wrote: 2. How do I get the list of strings to be displayed using a listbox?
like this,
mylist.ItemsSource = new List<string>() { "I", "LOVE", "WPF"};</string>
mylist is a ListView in XAML.I am setting the ItemsSource of mylist in the Window load event(code behind).
|
|
|
|
|
Thanks for your answer!
Now I need something more complicated (or not)...
I want to display the books the customer has rented.
Mark him those that he needs to return (rent date condition).
Let him select what books to return and get the selected items in the code behind (listbox is in SelectionMode="Multiple").
Any ideas for that one?
Thanks!
|
|
|
|
|
Not complicated at all. Try, and if you get stuck the forum will help you out.
|
|
|
|
|
I want to create a data template for a Book class (Name, Description, Genre etc.)
I know how to bind and template this but I am still missing a piece of the puzzle.
What I mean is Name and Description have one string value and my template binds perfectly to the fields in the class.
Problem I face is that Genre has some meta data behind it (Drama, Comedy, Horror etc.)
I created a Label and TextBlock for both Name and Description.
A ListBox for the Genres.
My Question:
How do I template the class' instance to display the whole list (in a list box for instance) while displaying the current genres selected ?
One data structure holds the genres available and the Book instance holds the specific genres.
Hope you understand what I am trying to say.
Thanks!
|
|
|
|
|
|
I want to add some custom properties as well as the existing properties should remain same in the controls.
Some of the controls can have the extended properties, but some controls like Textblock are sealed so can not be able to inherit other controls from the existing control.
Anybody have any idea that how can we extend the exisiting silverlight control's properties?
Thanks in advance...
|
|
|
|
|
If you want to extend an existing control, I'd look to use an Attached Property.
|
|
|
|
|
I have tried it with two ways:
1. Inheriting from teh existing control and add our custom property to it, include it in the xaml page as a new namespace and use it.
But it is not working in the case when the control class is sealed for example Textblock....
2. Created a wrapper class having the TextBlock and my custom property.Initialize the Textblock in constructor,include it in the xaml page as a new namespace and use it.
But it is also not working in the case when we give the "x:name" to that control...
No other idea how to do?
|
|
|
|
|
|
|
I'm not sure how many different ways to say this. Perhaps I need to shout here. USE ATTACHED PROPERTIES. That's it - full stop, finito. That's the WPF/Silverlight way of doing things.
There are very few instances where you need to subclass existing controls.
|
|
|
|
|
Pete O'Hanlon wrote: USE ATTACHED PROPERTIES. That's it - full stop,
easy, pete. sometimes, people just don't listen.
|
|
|
|
|
Thanks for ur kind support....
I didn't know about the attached properties, but now it become very useful for me...
|
|
|
|
|
I wrapped a class to call win32 api functions, use GetPrivateProfileString to get values in ini file.
it works in Unit Test, but does not work called in WPF window.
My project based on .NET FW 3.0, without any SP.
anyone know how to solve this?
Glad to discuss with you and best wishes.
|
|
|
|
|
If it works in a unit test, there's no reason it shouldn't work in WPF. I wouldn't use this API though, if I were you, because it's designed to provided compatibility with 16 bit applications. You should look to use either the registry or a config file for your settings.
|
|
|
|
|
Pete O'Hanlon wrote: If it works in a unit test, there's no reason it shouldn't work in WPF.
Agree with you, but it true, it happened.
Pete O'Hanlon wrote: You should look to use either the registry or a config file for your settings.
I intend to write my classes to read\write ini file. I prefer to ini files than xml file as config file.
Glad to discuss with you and best wishes.
|
|
|
|
|
Without seeing your project, there's not a lot I can suggest.
|
|
|
|
|
I've just uploaded the latest version of MoXAML PowerToys, complete with the Scrubber utility from Kaxaml - Robby said he wanted a version of Scrubber that worked in VS and I was glad to be able to help. You can get this here[^]:.
This version of Scrubber allows you to update all of the XAML in a project from a single menu option.
|
|
|
|
|
Hi everyone ,
haven't read much about WPF , just some basic stuff .
Is it possible to simulate first person movement in a WPF application ? can i dinamically move the view point or something like that to simulate this ? Like first person shooters , but without the shooting part . Just simulate the walk around a room ..
Thank you !
|
|
|
|
|
You can - WPF goes way beyond what you can do in WinForms and does allow you to work in a 3D environment. I'm not sure that you wouldn't be better off using Managed DirectX though.
|
|
|
|
|
Thank you so much ! I'll start digging in
|
|
|
|