|
R A Roldan wrote: Josh, you're the man
Yep. May I recommend you read all of his WPF articles with time permitting Plenty of good to learn from him.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Good people,
I have a window that is laid out using a grid. The main part of the user interaction will take place in column 1, row 0. In order for the user to submit or get information, I basically have to load and remove items (e.g. a flowdocumentviewer, another grid containing a border, list box, and other child elements, etc...) into column 1, row 0 of the grid. The loading and unloading will be, of course, menu driven by the user.
My question is, how do I load those elements into the grid at the desired location, then discard them when I am finished? Also how do I make sure that they're not using up memory but have been deleted or discarded? If they are not in view; I don't need them.
I will need to do this programmatically in C#.
A final tangential question; how would you recommend I create these elements? I am using MS Expression Blend and normally I would create something in column1, row 0. However, since I need to create multiple elements to fully occupy that space, I am wondering if I should do it as a control?
Any thoughts you have would be greatly appreciated.
Thanks in advance.
BP
|
|
|
|
|
Definitely do it as a ContentControl - it will save you so much time in the long run. Secondly, you can set the position of something in your code using Grid.SetRow and Grid.SetColumn in a UIElement.
|
|
|
|
|
Thanks. How do I create and delete it?
|
|
|
|
|
Off the top of my head (so I apologise now if it's not 100% accurate as I haven't got Visual Studio open right now):
using (StreamReader reader = new StreamReader("myControl.xaml"))
{
DependencyObject root = XamlReader.Load(reader.BaseStream) as DependencyObject;
if (root != null)
{
ContentControl cont = FindName("display") as ContentControl;
cont.Content = root;
}
} If you create the display page as a Frame, then you can load into this without any trouble. For instance:
<Window... usual Xaml declarations ..>
<Grid x:Name="myGrid">
<Grid.RowDefinitions>
<RowDefinition />
</Grid.RowDefinitions>
<Grid.ColDefinitions>
<ColDefinition />
<ColDefinition />
</Grid.ColDefinitions>
<Frame Grid.Row="0" Grid.Column="1" x:Name="display" />
</Grid>
</Window>
|
|
|
|
|
Thanks. I appreciate your help.
|
|
|
|
|
Hi,
I have created login and registration silverlight application using blend June Preview 2008. I would like to ask how to I link this two application in asp.net using visual studio 2008.
For example, I create an asp.net website and I would like to add the login and registration silverlight apllication in this website.When I click on the navigation link which created using asp.net such as login button, then the page will show the login silverlight application and it same to the registration as well.
Hence, how can I do for that??
Thanks.
Regards.
Katelva
|
|
|
|
|
Hello Katelva,
Actually, you can have login and registration in single Silverlight application. You can use them as the controls in Silverlight.
What you should do is that.
1) Go to VS 2008.
2) Create Silverlight Application with Web project (not with the generated Html)
3) Add one Silverlight control and name it as "LoginControl"
4) Add another Silverlight control and name it as "RegistrationControl"
5) Right-click on one of those XAML files and select "Open in Expression Blend" (then, you can customize the XAML as you like in Blend and save it and close the blend. )
6) Create the navigation in Page.xaml.
7) Run the application. (ASP.NET and Silverlight will be linked automatically and Silverlight control will be shown on aspx page. )
Hope it helps.
|
|
|
|
|
Hi Michael,
It means created the silverlight application which hosts in asp.net,am I right?
Actually, I would like to do is create Asp.net website(navigation), then when I click on the link it will appear the Login form in the asp.net webform which mean the design is using css and asp.net but the content such as registration form, login form...etc is using silverlight.
Can I do this way?
Thanks.
Regards,
Katelva
|
|
|
|
|
katelva wrote: It means created the silverlight application which hosts in asp.net,am I right?
Yes.
katelva wrote: Actually, I would like to do is create Asp.net website(navigation), then when I click on the link it will appear the Login form in the asp.net webform which mean the design is using css and asp.net but the content such as registration form, login form...etc is using silverlight.
In my opinion, you should consider two things. Do you want to use Silverlight partially with ASP.NET or do you want to create full Silverlight application (e.g. Hard Rock Cafe, etc)?
I will use Silverlight partially if I want to host Silverlight Game, Video/Audio Players, Silverlight Advertisements.
I will use Full Silverlight Application if I want to develop RIA application.
In your case, I would like to suggest you full-silverlight application instead of using silverlight partially.
|
|
|
|
|
Thanks for your suggestion.
But I would like to know whether there was any difficulty connecting the data with the MySQL database or not? Actually, I am creating a store website and the client can order the products online. Because Silverlight is new Microsoft product,hence, I am not sure whether have any issue with the database connection or not?
Regards,
Katelva
|
|
|
|
|
Hi Katelva,
Silverlight is a client-side technology which runs on the user's browser. so, you can't connect with any database directly from Silverlight. but you can create the service (i.e: ASMX webservice, WCF, ADO.NET Data Service, Java or Webservice that follows WS Basic-Profile 1.1 ) and you can connect with that web service.
there are a few samples how to do CRUD (Create, Retrieve, Update, Delete) operation in Silverlight in my blog. you may want to read them.
|
|
|
|
|
Hi,
I'm relatively new to WPF and am still trying to get my head around certain aspects so if this is a stupid question please accept my apologies in advance.
I have a listbox that is bound to a list of custom objects.
Based on the value of a property in each object I want the listbox item to be displayed differently
The data binding is working fine and the item template that I am using works fine, my problem is in changing the item template based on a property value.
Trivial example:
Assume I have a class Person with two properties : Male and Female
If Male == true I want the listbox item to be rendered as a grid with three rows and 2 columns
If Female == true I want the listbox to be rendered as a grid with a single row
Is this possible?
Thanks very much,
dlarkin77
|
|
|
|
|
We do something like this by having a base listboxitem class, then having derived classes which have styles, and which we use to add items. We mix styles within the listbox tho, sounds like you want to have one or the other. I am asking something similar below, and a Property Trigger is what was suggested for me.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
I would start by looking at using triggers in the style of the data template given to the ItemTemplate property. On a hunch, the style will probably not do quite what you need since it sounds more like you are using two different data templates. In that case, I would look at the ItemTemplateSelector property, which takes a DataTemplateSelector (documentation on MSDN).
|
|
|
|
|
Thanks for the advice. I'll look into both of those.
|
|
|
|
|
Hi,
Using a DataTemplateSelector solved my problem.
Thanks very much,
dlarkin77
|
|
|
|
|
[WPF]why Image not support Animation ?
MessageBox.Show(item.HasAnimatedProperties.ToString());//false
it return false , How to move it from a Point to another Point ?
thanks !
|
|
|
|
|
Put it in a stackview or grid.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
I have a slider and I want to change the bitmap used for the slider control, and the size of the slider, based on a boolean property.
So within a style for the slider, I want to change ' Slider_Thumb' in the following:
<Track Name="PART_Track">
<Track.Thumb>
<Thumb x:Name="Thumb" Style="{StaticResource Slider_Thumb}"/>
</Track.Thumb>
</Track>
and the height in this line:
<Setter Property="Height" Value="16" />
How do I go about doing that ?
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Christian - take a look at this[^] article from Sacha and Marlon. They have restyled the slider control (about 3 quarters of the way down).
|
|
|
|
|
thanks - but i think they are just styling it. I've done that. I want to change the style I use, in code, based on a property
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Where does the boolean property come from?
If it is one of the Sliders or Thumbs properties a Trigger will work. See the ControlTemplate example for slider, it uses a Trigger to change the color of the thumb on mouse over and change the size of the slider based on its orientation.
If the property is from elsewhere a DataTrigger might work but you would probably have to alter your resources a bit.
|
|
|
|
|
Looks promising - thanks.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|