|
Hi,
Can anyone suggest me from where I can get an advanced Flip Book control for my WPF 3.5 SP1 application?
Any help regarding the same is highly appreciable.
Thanks in advance.
Regards,
- Kunal Chowdhury ( My Blog)
|
|
|
|
|
There's this[^] control.
"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
|
|
|
|
|
I'm working with the Telerik WPF controls, and I'm trying to derive a new class from one of their controls. I'm adding some visual components (a titlebar and a toolbar) to their grid view template, and I want to be able to change some of the properties of those components via XAML. I've accomplished all of this, but I have a problem.
My derived class contains the attached property stuff, and the way that these properties are "set" is via the OnApplyTemplate() method. However, if I add that method to the class, the grid refuses to show the data items. This is true regardless of what's in the method (even if it's just a call to base.OnApplyTemplate() ). If I *don't* include that method, the attached properties aren't applied.
I don't understand why this might be happening. I used reflector to see what the RadGridView is doing, but it's just calling *it's* base method, and setting some sample data if there is no data bound to the grid.
So the problem is with the OnApplyTemplate() method. Is there another way to apply attached properties or am I just doing this wrong?
EDIT ====================================
I approached the problem from a different direction. It's a bit bulkier than deriving from Telerik's class, but I got it to work. I ended up creating my own custom control that is just the stuff I wanted to add to the Telerik-derived control. This allowed me to play with the code without hosing up their RadGridView. It took about 6 hours to do the whole thing, but it now works. I'm not happy with what I've ended up doing because I just know what I really wanted to do is entirely possible, but I simply don't know the magic words to make it go. I need to move on with the project, so I'm going to leave it as is, and maybe poke at it in my spare time.
Telerik was of no help at all. Instead of trying to do what I described (since they're evidently much better at WPF than I am), they pestered me for sample code, and even suggested that I create a UserControl , of all things. A user control is fine if you only need one, but I have DOZENS of grids in this application, and I'm not going to write a UserControl for each one.
I'm already not fond of their stuff because their ideas on theming are so bizarre as to morph into major suckage. Oh yeah - the vertical scrolling on their grids are hopelessly screwed up.
"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
modified on Monday, July 20, 2009 6:22 AM
|
|
|
|
|
Hi All,
I wrote I silverlight application a while back and I needed to convert it into a WPF executable. I did this in about a day, but I have already spent a couple of days trying to figure out a way for the wcf application to keep my session variables.
Example of what I am doing:
WPF Client:
wcl.CheckUserAsync("username","password");
WCF:
public bool CheckUserAsync(string userName, string password)
{
if (isValid(userName, password))
{
System.Web.HttpContext.Current.Session["userName"] = userName;
return true;
} else {
return false;
}
}
WPF Client:
wcl.GetUserNameAsync();
WCF:
public string GetUserName();
{
return System.Web.HttpContext.Current.Session["userName"].toString();
}
So my problem is that System.Web.HttpContext.Current.Session["userName"].toString() = null at this point. I know that the reason this is not working in the WPF application is that I do not have a cookie where I can store the session id. I have been looking everywhere...google and books....and have not found a clear explanation of how to store the session id in a cookie in my WPF app. Can anyone help with this?
Thanks
|
|
|
|
|
System.Web.HttpContext is ASP.NET, not WCF. You may want to understand how
WCF interacts with ASP.NET.
There's some more info here: WCF Services and ASP.NET[^]
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Thanks for the reply Mark,
I understand that it is asp .net. I have the service running in asp net compatibility mode. I should have that made that more clear, sorry.
What I am trying to mimic in my wpf executable is the retrieval of the session id from asp .net, save that session in a cookie, retrieve it and send that session id back on my next call to the server.
Thanks
|
|
|
|
|
jeremyadell wrote: What I am trying to mimic in my wpf executable is the retrieval of the session id from asp .net, save that session in a cookie, retrieve it and send that session id back on my next call to the server.
In ASP.NET compatibility mode that should happen automatically if
you set AllowCookies to true on the client service binding.
You want to do that manually?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Mark,
Thanks a ton for your help. Adding the allowCookies="true" attribute to my binding fixed it. The silverlight to WPF conversion works perfectly now. This was my first executable that called a web service and needed cookies. I searched for days online trying to figure out how. Amazing how simple it was.
|
|
|
|
|
I did this a couple years ago under MFC but it required going to COM, C++ code like this:
HRESULT Sheet::UpdateLink(CString strSourcePath, CString strLinkPath,
CString strDesc, CString strArguments)
{
HRESULT hres;
IShellLink* psl;
hres = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER,
IID_IShellLink, (LPVOID*)&psl);
if (SUCCEEDED(hres))
{
IPersistFile* ppf;
hres = psl->QueryInterface(IID_IPersistFile, (LPVOID*)&ppf);
if (SUCCEEDED(hres))
{
LPOLESTR oleLinkPath = (LPOLESTR)(LPCTSTR)strLinkPath;
hres = ppf->Load(oleLinkPath, STGM_READWRITE);
if (FAILED(hres))
{
}
hres = psl->SetPath(strSourcePath);
hres = psl->SetDescription(strDesc);
if (strArguments.GetLength())
{
hres = psl->SetArguments(strArguments);
}
hres = ppf->Save(oleLinkPath, TRUE);
ppf->Release();
}
psl->Release();
}
return hres;
}
I'd like to think those days are history, but after researching for a couple hours, I couldn't find a single mention about how to do this under WPF, or under .NET in general. Is there a way?
If I do have to use COM, how difficult would it be to wrap the above UpdateLink function into something I could call from WPF?
So far I've avoided going to unmanaged code by using System.Runtime.InteropServices stuff. I've done lots of neat stuff with functions in shell32.dll, like applying bitmaps to buttons and labels, sending files to the recycle bin (using SHFileOperation), calling ShellExecuteEx, etc., but no COM stuff. Is there a nightmare in my future if I try to do this?
|
|
|
|
|
WPF has nothing to do with it. You do it by copying shortcuts to the right locations, same as for any C# app.
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 thought I had to programmatically create shortcuts in MFC using COM. If so, how do I do it in .NET? This is how I did it in my code I originally posted:
hres = psl->QueryInterface(IID_IPersistFile, (LPVOID*)&ppf);
if (SUCCEEDED(hres))
{
LPOLESTR oleLinkPath = (LPOLESTR)(LPCTSTR)strLinkPath;
hres = ppf->Load(oleLinkPath, STGM_READWRITE);
if (FAILED(hres))
{
}
hres = psl->SetPath(strSourcePath);
hres = psl->SetDescription(strDesc);
if (strArguments.GetLength())
{
hres = psl->SetArguments(strArguments);
}
hres = ppf->Save(oleLinkPath, TRUE);
ppf->Release();
It sounds like you think that original MFC/COM code was way overkill and that I made a mountain out of a molehill.
Give me a coding example of the extremely simple way you have in mind.
|
|
|
|
|
private void urlShortcutToDesktop(string linkName, string linkUrl)
{
string deskDir = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
using (StreamWriter writer = new StreamWriter(deskDir + "\\" + linkName + ".url"))
{
writer.WriteLine("[InternetShortcut]");
writer.WriteLine("URL=" + linkUrl);
writer.Flush();
}
}
I found this on the web. deskDir is the folder to which you need to write a shortcut to your program.
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.
|
|
|
|
|
That's absolutely wonderful if it works. I'll give it a try and let you know how it works out.
|
|
|
|
|
Thanks a lot, Christian. Magic that I didn't know about: "[InternetShortcut]". I Googled for that and found out how to extend your code to get the icon out of the linkUrl. Here is my code combining your suggestion with the extension:
writer.WriteLine("[InternetShortcut]");
writer.WriteLine("URL=" + linkUrl);
writer.WriteLine("IconFile=" + linkUrl);
writer.WriteLine("IconIndex=0");
writer.Flush(); The next thing to do is to programmatically add links to the Quick Launch bar. For that you have to get the path to the Quick Launch folder. I do that in the following function, which is like yours, except it generates a path to the Quick Launch folder and also establishes the icon:
private void ShortcutToQuickLaunchFolder(string linkName, string linkUrl)
{
string appData = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
string quickLaunchFolder = appData + @"\Microsoft\Internet Explorer\Quick Launch";
using (StreamWriter writer = new StreamWriter(quickLaunchFolder + "\\" + linkName + ".url"))
{
writer.WriteLine("[InternetShortcut]");
writer.WriteLine("URL=" + linkUrl);
writer.WriteLine("IconFile=" + linkUrl);
writer.WriteLine("IconIndex=0");
writer.Flush();
}
} Everything works beautifully! Hope this is useful for other people.
|
|
|
|
|
I discovered a big limitation that .lnk files do not have. The URL File Format apparently does not support command line parameters, so if a program has several modes of operation, you're stuck. I tried specifying a batch file to invoke the program, where the batch file contains the full path of the executable plus a command line parameter and it didn't work.
|
|
|
|
|
Hi fjparisIII,
I am new to creating setup...and just a beginner. Could you please tell me where should i write this function "ShortcutToQuickLaunchFolder(string linkName, string linkUrl).
Thank you very much
|
|
|
|
|
I scratch-built my own setup program in two days, just using core .NET API's. I don't use an MSI file. I figured writing my own setup program from core .NET API's would be faster than learning how to link into the MSI infrastructure and API. I don't even know if there is an MSI API. You probably know more than I do if you can even ask this question.
|
|
|
|
|
FWIW, writing a shortcut file directly is poor practice IMO, and could
lead to tears in the future.
IShellLink is the proper way to go (has been since Windows 95). Here's an
example of using it from a .NET app:
Creating and Modifying Shortcuts[^]
If that's too much, then the second best option would be to use the Windows Script Host.
Here's one example:
How to create Windows shortcut (C#)[^]
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Mark Salsbery wrote: writing a shortcut file directly is poor practice IMO, and could
lead to tears in the future.
Was never proposing that.
Mark Salsbery wrote: IShellLink is the proper way to go
If you saw my original MFC code that I quoted, you'd have seen that that's what I originally did, and what I was asking was how hard it would be to wrap that COM code into something that could be called from WPF? Would I have to go to unmanaged code? I don't want to do that.
|
|
|
|
|
Mark Salsbery wrote: If that's too much, then the second best option would be to use the Windows Script Host.
Here's one example:
How to create Windows shortcut (C#)[^]
This looks like the way to go. Don't know anything about Windows Script Host, but the reference is just a recipe I could probably follow.
|
|
|
|
|
Hi,
Recently I'm trying to learn WPF, and I've stumbled across a problem, I can solve it, but I'm not happy with the result code, so maybe someone could help me to polish it a bit.
Let's say, I have class XManager, that manages classes X, also, it has reference to currently active X instance, each class X has it's own Text property, I want to do a two way binding between textbox and this text property.
It looks like this:
class XManager
{
private X activeX;
public X ActiveX
{
get { return activeX; }
}
}
class X : INotifyPropertyChanged
{
public string Text { get; set; }
public void PutSomeTextProgramatically(string someText)
{
Text += someText;
if (PropertyChanged != null)
PropertyChanged(this, new PropertyChangedEventArgs("Text"));
}
}
Now, I do have a manager accessible from XAML:
<Windows.Resources>
<local:XManager x:Key="xManager"/>
</Windows.Resources>
My binding to it looks like this:
<TextBox Name="someBox">
<TextBox.Text>
<Binding Mode="TwoWay" Source="{StaticResource xManager}" Path="ActiveX.Text" />
</TextBox.Text>
</TextBox>
Such code won't work properly, because we've binded to XManager's "ActiveX.Text", but we never change it, so workaroun I did was to add do my manager such code:
void XSession_PropertyChanged(object sender, PropertyChangedEventArgs e)
{
if (e.PropertyName == "Text")
{
if (PropertyChanged != null)
PropertyChanged(this, new PropertyChangedEventArgs("ActiveSession.Text"));
}
}
Now it will work, but I find such code a bit ugly, I'd like to bind "directly" to PropertyChange event inside XSession, not to some sort of a wrapper. Is this possible, or maybe I don't see something obvious?
|
|
|
|
|
The Path "ActiveX.Text" should be "Text"
Change to: <Binding Mode="TwoWay" Source="{StaticResource xManager}" Path=".Text" />
BTW: Any reason you're not setting the DataContext on the TextBoxes Parent container to an instance of the xManager class? Then you don't need a resource. Your application may need to follow the pattern you've described, just want me sure you knew there are other ways.
Also, xManager is not public. I've run into problems when the classes exposed on the UI are not public. Not all cases, just mentioning I've hit issues.
modified 27-Feb-21 21:01pm.
|
|
|
|
|
Karl Shifflett wrote: The Path "ActiveX.Text" should be "Text"
Change to: <Binding Mode="TwoWay" Source="{StaticResource xManager}" Path=".Text" />
I've actually did, just forgot to include this change in my post , actually, I've manage to make it work without this wrapper thing on XManager. If I would set Path="Text", I'd have to include this wrapper, so XManager would have to catch it's activeX text change and repost it, but now for some reason I am able to set two way binding without this wrapper, just binding to Path="ActiveX.Text" (it did not work earlier heh).
Karl Shifflett wrote: BTW: Any reason you're not setting the DataContext on the TextBoxes Parent container to an instance of the xManager class? Then you don't need a resource. Your application may need to follow the pattern you've described, just want me sure you knew there are other ways.
This may be a newbie question, but how I do that? If I won't add the XManager to window resources, but only create it's instance in the code part, I don't see any of binding to it, I was actually thinking is it possible to bind to an instance of a class that was created in code, but I gave up and just used resources.
|
|
|
|
|
DataContext is KEY to programming in WPF. Without a full understand of this property you will struggle with WPF when infact it's super powerful and simple (once you grasp how it works.)
Strongly recommend you read, print, study, this post: http://msdn.microsoft.com/en-us/library/ms752347.aspx[^]
It's some VERY good Microsoft documentation on Data Binding.
Another fantasic WPF Data Binding resource is: http://bea.stollnitz.com/blog/[^]
modified 27-Feb-21 21:01pm.
|
|
|
|
|
I do get your point, I just don't see why I can't use XManager as a resource, and how else I can refer to it's instance, if I won't declare it this way? I'm using Data contexts with success while referring to resources, using
DataContext="{Binding Source={StaticResource resourceKeyName}}"
|
|
|
|
|