|
At this point I introduce my bastardisation and have 1 CustomerVM that would service all 3 of your views.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Mycroft Holmes wrote: 1 CustomerVM that would service all 3 of your views.
that's fine - but what if you want to use the customer lookup view elsewhere - not for editing a customer but for selecting a customer for some other function (say during order entry) You don't want to use that VM with all its overhead do you? soyou would end up with aniother ViewModel supporting the Customer lookup View...
I appreciate you call it a bastardisation - but what you're really doing is treating the containing user control as a View, with a ViewModel, and the other two as user Controls (not views) so they don't have a view model any more than a text box or combo box would. And that's fine - I just find it very confusing if you call something a View that is really just a control - and if it's not just a control, i.e. if it is a View, then it should be modelled by a ViewModel -and a ViewModel's job is to model a view (otherwise they'd be called ViewsModels)
|
|
|
|
|
Oh I'm flexible, for simple list/add dialog/detail I often have 2 views and a dialog using the same VM. If a view is particularly complex then it gets it's own VM even if that is duplicating info already in an existing VM. And no I have no intention of renaming them VsM
_Maxxx_ wrote: I just find it very confusing if you call something a View that is really just a control
The list view is the entry point into the structure, the detail view is distinct, navigated to via a double click from the datagrid on the list view, the add dialog is obviously a childwindow from the list view. All 3 use the same VM, calling the detail view a control is not correct, the dialog maybe.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Mycroft Holmes wrote: All 3 use the same VM, calling the detail view a control is not correct, the dialog maybe.
I see exactly what you're talking about - and it's really down to terminology - but in my view (pub intended) the VM models a V, and if there isn't a specific Vm then it's not a V, it's just a control - as it cannot be used (or tested) stand-alone.
It was partly because of this that I introduced the concept of ViewData separate from (but used by) the ViewModel
|
|
|
|
|
Good Day All
I have a Generic function that in my Static Class. i have this Class in Silverlight
public static BitmapSource LoadImage(Byte[] imageBytes)
{
BitmapImage bmpImage = new BitmapImage();
MemoryStream mystream = new MemoryStream(imageBytes);
bmpImage.SetSource(mystream);
return bmpImage;
}
Now this looked fine for me until i had to bind an Image in Silverlight like this
PhotoHolder.Source =GenericMethods.LoadImage(model.imbPhoto);
The Images i have in the Database are Supported by silverlight they are jpg type.
and the Elelment that i am binding to look like this in Silverlight
<Image x:Name="PhotoHolder" Height="98" Width="102" OpacityMask="Black" Canvas.Left="141" Canvas.Top="30">
<Image.Effect>
<DropShadowEffect/>
</Image.Effect>
</Image>
so if i bind i get this Error
Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED))
Thanks
Vuyiswa Maseko,
Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code.
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.com
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
Where does the exception occur??
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
hi
it happen on this line
bmpImage.SetSource(mystream);
i have used the Correct Image Format that are supported in Silverlight.
Vuyiswa Maseko,
Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code.
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.com
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
It should work with valid JPEG bytes...
I tested your LoadImage() method but with JPEG bytes loaded from disk and it works fine:
private void loadButton_Click(object sender, RoutedEventArgs e)
{
OpenFileDialog ofdlg = new OpenFileDialog();
ofdlg.Filter = "Image Files (*.jpg, *.jpeg, *.png)|*.jpg;*.jpeg;*.png";
if (true == ofdlg.ShowDialog())
{
long filelength = ofdlg.File.Length;
Byte[] imageBytes = new byte[filelength];
using (FileStream fs = ofdlg.File.OpenRead())
{
fs.Read(imageBytes, 0, (int)filelength);
}
PhotoHolder.Source = GenericMethods.LoadImage(imageBytes);
}
}
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Now i have a Different Error in the same place
Error HRESULT E_FAIL has been returned from a call to a COM component.
THANKS
Vuyiswa Maseko,
Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code.
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.com
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
Silverlight COM component? hmm I have no idea. It works fine for me with valid JPEG files (and PNG files).
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
trying to copy and paste text containing hyperlink from one richtextbox to another with TextPointer position as parameter.
tried using the following code but couldn't figure out what the problem is. it did not work.
private Hyperlink GetHyperlinkAncestor(TextPointer position)
{
Inline parent = position.Parent as Inline;
while (parent != null && !(parent is Hyperlink))
{
parent = parent.Parent as Inline;
}
return parent as Hyperlink;
}
- Regards - J O N
A good thing is a bad thing if it keeps you from the best thing. - Dr. Adrian Rogers
|
|
|
|
|
I have created a WPF control, which I want to deploy to the user.
I need to create an installer for this control. Installer should create a custom tab in VS toolbox and place the control inside that tab, the way it is done by other WPF control installers (e.g., Telerik).
Any help/idea?
|
|
|
|
|
|
Many thanks for your reply. I tried google before asking question here, but none of them (including this one) could fulfill my requirement.
When I install Telerik with the help of their EXE, it just installs everything without being specific to any application. It puts that control into a specific tab in VS toolbox and also places it into 'Assets' tab of 'Expression Blend' without asking any question.
This .vsi file, including dialog box and messages, seems to be specific to Visual Studio and asks questions before installing.
|
|
|
|
|
This [^]could help you as well.
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.
|
|
|
|
|
Good Day All
I have another question. I have a Silverlight application and in one of the Silverlight pages i am hosting an Asp.net Page using a RadhtmlContainer(Telerik). I created a Cookie in Silverlight like this
public static void SetCookie(string key, string value)
{
DateTime expiration = DateTime.UtcNow + TimeSpan.FromDays(2000);
string cookie = String.Format("{0}={1};expires={2}", key, value, expiration.ToString("R"));
HtmlPage.Document.SetProperty("cookie", cookie);
}
and i have the same generic function to access it like this
public static string GetCookie(string key)
{
string[] cookies = HtmlPage.Document.Cookies.Split(';');
key += '=';
foreach (string cookie in cookies)
{
string cookieStr = cookie.Trim();
if (cookieStr.StartsWith(key, StringComparison.OrdinalIgnoreCase))
{
string[] vals = cookieStr.Split('=');
if (vals.Length >= 2)
{
return vals[1];
}
return string.Empty;
}
}
return null;
}
so i am trying to access this cookie in an asp.net page that is hosted on the the html Container , but i dont find the cookie.
Basically what i want to Achieve is
i want to access a value that is being created in Silverlight e.g "userid" "Username" normally i store it in the Cookie , so now i want to do a database insert , i need to do that insert from that asp.net page, but i cant get hold of that cookie value.
Thanks
Vuyiswa Maseko,
Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code.
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.com
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
What do you see in HtmlPage.Document.Cookies when you enter the GetCookies method? It would really help if you set a breakpoint there and told us what was in that part? Plus, and I know this seems obvious, but make sure that the SetCookie method is called before you call GetCookies.
|
|
|
|
|
Good Evening Pete
Thank you for your kind response.
The First thing i do is to set the Cookie when the User has Just Logged in and after that that the User will be redirect to a Welcome page. There are Menu's that are visible for the User to select , and one of them will lead to a Silverlight page that will require the Cookie value that has been set at Login.
So the above explanation your last point that i should first set the Cookie and Access it later
To answer the first question about the htmlpage.Document.Cookies , it has an empty string i am not sure why.
Thanks
Vuyiswa Maseko,
Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code.
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.com
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
From your description, the cookies are added by the website and not by Silverlight. It looks like you are trying to read the cookies created in the ASP.NET side, in your Silverlight code. According to MSDN[^], Cookies are disabled by default for security reasons. Use WebClient instead.
|
|
|
|
|
Can you pass the cookie value into the silverlight app as an initial parameter?
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
the thing is i want the value out of Silverlight to aspx
Vuyiswa Maseko,
Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code.
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.com
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
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++
|
|
|
|