|
I have a SL site that is structured like
Corporate
- Company1
- Company2
- Company3
- Company4
Entry to the site is www.corporate.com
Each company now wants to basically skin their area of the site with thier company identity and to access their area directly skipping the corportate.com page. I know I can change skins (never having built a skin this is an assumption) so what is the recommended method of going directly to the company pages based on the URL.
All will use the same xbap, wcf and database it is just the entry point for the companies.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Mycroft Holmes wrote: what is the recommended method of going directly to the company pages based on the URL.
Easy using navigation![^]
Mycroft Holmes wrote: All will use the same xbap
XBAP? That's WPF...and not even recommended anymore
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Mark Salsbery wrote: Easy using navigation![^]
Pfft alreay half way there I implemented navigation right from the start, just never went past the minimum required for our needs. thanks...
Mark Salsbery wrote: XBAP? That's WPF...and not even recommended anymore
What, that's what lives in my clientbin folder and thats what gets deployed (along with the dafault.aspx), when did they go out of fashion, link required. Your had better mean you are taking the mickey or I've got some serious reading to do.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Mycroft Holmes wrote: What, that's what lives in my clientbin folder and thats what gets deployed
Ohhh the XAP? XBAPs are WPF browser applications...Silverlight is recommended over XBAPs, although you can still do them.
And the smiley was just because I was nit-picking terms but not real seriously...
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Oops - did not even notice the mistake thank ghu I thought I may have completely screwed up.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
It turns out that the link does not actually help me, I don't expose the url eg www.corporate.com?companyid=1 However I guess I should be able to use mymapper to hard code the url. Pick up www.corporate.com/CompanyName in mymapper and deal with it.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
The domain "www.corporate.com" doesn't need to be in the code, does it?
According to your original post, you should only need something like this
<navigation:Frame.UriMapper>
<uriMapper:UriMapper>
<uriMapper:UriMapping Uri="/Company1" MappedUri="/Views/Company1.xaml"/>
<uriMapper:UriMapping Uri="/Company2" MappedUri="/Views/Company2.xaml"/>
<uriMapper:UriMapping Uri="/Company3" MappedUri="/Views/Company3.xaml"/>
<uriMapper:UriMapping Uri="/Company4" MappedUri="/Views/Company4.xaml"/>
</uriMapper:UriMapper>
</navigation:Frame.UriMapper>
or better yet, to not hard-code company names in the code...
<navigation:Frame.UriMapper>
<uriMapper:UriMapper>
<uriMapper:UriMapping Uri="/{pageName}" MappedUri="/Views/{pageName}.xaml"/>
</uriMapper:UriMapper>
</navigation:Frame.UriMapper>
Mark Salsbery
Microsoft MVP - Visual C++
modified on Wednesday, May 25, 2011 4:36 PM
|
|
|
|
|
How do you eliminate the # requirement. Currently the nav wants
www.Corporate.com/#Company1
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
If you create and build a SIlverlight Navigation Application from the visual Studio project templates and run it, you'll see there's no "#" requirement.
I'm not sure where that would come from
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Mycroft Holmes wrote: I know I can change skins (never having built a skin this is an assumption
Good assumption - yes you can[^].
The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it.
|
|
|
|
|
Hi all,
I am still digging into WPF and last night have a look around with User Controls.
If I said that User Controls are more likely the templates, where I can reuse later time, what you think? Any comments really appreciate.
Thanks
I appreciate your help all the time...
CodingLover
|
|
|
|
|
I personally would not associate UserControl with the word "template" in WPF/Silverlight, since a "template" in these frameworks has a specific meaning.
Some info on UserControls compared to other controls... Control Authoring Overview[^]
*edit* fixed link
Mark Salsbery
Microsoft MVP - Visual C++
modified on Wednesday, May 25, 2011 5:06 AM
|
|
|
|
|
Thanks for the reply.
May be that I have not enough experience with WPF. I agreed with you, comparing with ASP.Net and so on, word template is not relevant. Basically it has a different meaning.
Why I wonder is that I can use the same XAML in different places as well. Is there anything in WPF named as 'templates' ?
Thanks for the link as well, sounds good it is.
I appreciate your help all the time...
CodingLover
|
|
|
|
|
CodingLover wrote: Is there anything in WPF named as 'templates' ?
Oh yes!
Styles and Templates[^]
(fixed link in post above)
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Mark Salsbery wrote: Oh yes!
Let see, still I'm working on with user controls.
Mark Salsbery wrote: (fixed link in post above)
Thanks
I appreciate your help all the time...
CodingLover
|
|
|
|
|
Hi,
I am new to MVVM and trying to implement it in my application.
I have a develop a GUI which will interact with the Hardware through some protocol. This is first experience under this space.
Just to keep things simple, consider I have a hardware which contains Voltage and Resistance parameter at different sections of the hardware.
View
----
So, I have total 5 sections. Each of them contains 15 different Voltages and Resistance.
In my WPF GUI, I am representing these 5 sections in a tab control.
I have created a user control(PowerControl) that contains 2 sliders for Voltage and Resistance. Voltage varies from 0-120v and Resistance varies from 1-10 ohm.
Each of the sections in the tab control contains 15 user controls.
Model
-----
I am planning to create a class Power which has 2 properties for voltage and Resistance.
ViewModel
---------
I am planning to create a class 'PowerViewModel' to represent the Power model. It will have two properties which will have INotifyProperty changed event.
The change from the slider has to be conveyed to the hardware and it is done through a set of uniquely identified parameter.
Such as if a slider on the PowerControl of section 2(tab2) is moved, it 'll be represented as "PC2, section2, value of slider". So, its a combination of these three things and I used to send it the hardware which displays it in the hardware display.
Here are my questions.
1- Where should I write the unique ID's? Should it be in the Model or ViewModel?
2- How should we bind the slider as per their ID's?
3- How does my Model know which slider has been moved?
4- How can we apply MVVM here?
Thanks in advance and please feel free to ask for any clarification on this.
Praveen Raghuvanshi
Software Developer
|
|
|
|
|
I'll take a stab here...
If the IDs don't need to be in the model then they should be used in the viewmodel.
But, if you have separate objects in your view model - each associated with individual PowerViewModel objects, then you can bind those to each user control. Then you don't need IDs and the model knows what slider is moved.
Mark Salsbery
Microsoft MVP - Visual C++
modified on Tuesday, May 24, 2011 4:53 PM
|
|
|
|
|
Appreciate the quick response. I'll try it.
Praveen Raghuvanshi
Software Developer
|
|
|
|
|
For MVVM you're kinda doing it the wrong way around - you should create your VM first and then design a view. Anyhow, I know lots of people work better visually, so:
You have five sections each with a collection of 'Voltages and resistances'
So you want a SectionViewModel that contains a collection of VoltageAndResistanceViewModels - each of which has a Voltage property and a resistance property -which utilise INotifyPropertyChanged
Then you want another ViewModel that contains a collection of the SectionViewModel
I'd say that when you instantiate each of your ViewModels you'd need to tell them which unique Id for the hardware they are representing. This information (I would htink) would be contained in the model as a series fo collectins - so you would construct your collection of ViewModels based upon these collections, hence the Model has the unique Ids, which are referenced by the viewModels
Each slider would be bound in Xaml to the appropriate property of the particular VM to which the View is bound
When the property of the Vm is changed, if necessary that's the time to adjust the property on the model - the model can then do whatever it does in order to update the machine's value.
Hope that helps at least a little!
|
|
|
|
|
Appreciate the quick response. Very well explained. I'll try it
Praveen Raghuvanshi
Software Developer
|
|
|
|
|
I'm working on a WPF app using MWWV. I passed a data model into the CTOR of the viewmodel and set the bound properties from it.
In the view, is it possible somehow to set the width of a textbox based on the size of a field in the DB? How would you even know the width using MVVM?
Everything makes sense in someone's mind
|
|
|
|
|
Kevin Marois wrote: is it possible somehow to set the width of a textbox based on the size of a
field in the DB
Are you talking about setting the width of a textbox based on the size of the field, so if you had an NVARCHAR(50), you'd set the width for 50 characters? If you are, then your ViewModel would have a property which you'd set with this value multiplied by the width of the widest character in the font you are working with (this would normally be W in a Latin font).
In order to work out what the width of the font is, you have the choice of precalculating it and applying it as a constant, or you can use the following code:
FormattedText formattedText = new FormattedText("W", CultureInfo.GetCultureInfo("en-GB"), FlowDirection.LeftToRight, new Typeface(textBox.FontFamily.ToString()),
textBox.FontSize, Brushes.Black);
|
|
|
|
|
If the table has a name field whih is 50 characters, then I want the field on the form to be wde enough to accept 50 characters.
Everything makes sense in someone's mind
|
|
|
|
|
You are going to run into a problem with your idea... WPF UIs use TrueType fonts. For example, on my screen 10 W's are about 4x as wide as 10 i's. You'd have to size your field to fit W's since that is the widest character (in English -- USUALLY), so you'd end up with a bunch of empty space for most other characters since they are much narrower. You could switch to a fixed width font, but then it wouldn't match the rest of the UI and you'd lose various functionality / behavior from TrueType fonts.
If you still want to go down that route, Petes code snippet will allow you to calculate the width you need, then you'll need to add in some padding depending on the control.
|
|
|
|
|
Then if you follow my suggestion, you should be OK.
|
|
|
|