|
If you are using Visual Studio 2010, open the window/user control in the designer and then select the control you want to add an event for. In the properties panel, there's an Event tab that you can use to choose the event.
|
|
|
|
|
Hello Everyone,
My XBAP Appication is having two things web server and web client.
There is another machine where I am sharing a folder to Windows user(Of Client Machine) which is mapped to client as x: drive.
I need to generate PDF/XLS/TXT file to that mapped drive path which is given by client as destination path.
I am passing UNC Path to server But While doing Directory.GetAccesscontrol it throws an exception 'DirectoryNotFound Exception'.
Here is the Code..
(CODE RUNS ON CLIENT)
{
string FolderUNCPath = GetUNCPath("x:\\Reporting\\Reports"); //(x is Mapped drive)
}
(CODE RUNS ON SERVER)
{
string folderPath = "\\\\AnotherMachine\\Reporting\\Reports"; //(Which is FolderUNCPath...)
DirectorySecurity dirSecurity = Directory.GetAccessControl(folderPath);
}
Throws exeception..(DirectoryNotFound)..
Thanks all in Advance.
Ashish Parmar
|
|
|
|
|
I only ask this question because MSDN says its not allowed, but some posts on the internet say it is allowed, but in my experience, it works 50% of the time. Kind of a shame to not allow binding to internal or protected internal types because that means having to expose private DPs to the world just so you can bind to them.
In regards to my 50% example... I have an internal DP in a ListViewEx : ListView class and ListViewItemEx : ListViewItem can bind to it all day long with no problem.
Copied the code exactly to a TreeViewEx : TreeView class and TreeViewItemEx : TreeViewItem class and the TreeViewItemEx can't access the internal property.
WEIRD.
|
|
|
|
|
Ah you want a discussion, I was just going to parrot the doco. I do know non public does not work, one of the early gotchas I found. "Ok I know I've create the property, there it is in the viewmodel why can't the bloody view see it" - private DUH!
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I don't think I've ever seen a private property work in any scenario. Ditto for protected internal. Internal by itself works in a lot of scenarios. I am binding to some internals as we speak. The reason it didn't work earlier was a C&P error . Changed everything from ListViewEx to TreeViewEx except the class type for the registration on the new DPs. Once I changed the new DPs to be registered for the right class, it allowed me to bind to internals.
I don't mind have internal, protected internal or private properties that I use internally for my own nefarious purposes... but I do mind having a public CheezyHackDP .
|
|
|
|
|
SledgeHammer01 wrote: but I do mind having a public CheezyHackDP
That'll teach you to get smart with your naming, I tend to keep the vitriol and disgust to the comments, at least then it has a limited audience.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I am trying to automate email sending using OUTLOOK Introp. I have a Rich text box in my application to allow user to edit and format the body of the message. Now this Formatted text needs to be copied into Outlook MailItem but whenever i try to do so the content loses its formatting even when i have changed the mailitems.bodyformat to Outlook.OlBodyFormat.olFormatRichText;
Please suggest a solution.
|
|
|
|
|
The issue you see here is that the WPF RichTextBox is unlike any MS RichTextBox released before it. It doesn't actually support RTF directly, so you need to perform a little trick which is to use the TextRange and save to a MemoryStream. Here's a couple of handly little extension methods you can use:
public static string FormattedSave(this RichTextBox rtb)
{
return FormattedSave(rtb, System.Windows.DataFormats.Rtf);
}
public static string FormattedSave(this RichTextBox rtb, System.Windows.DataFormat dataFormat)
{
TextRange range = new TextRange(rtb.Document.ContentStart, rtb.Document.ContentEnd);
using (MemoryStream ms = new MemoryStream())
{
range.Save(ms, dataFormat);
string retVal = ASCIIEncoding.Default.GetString(ms.ToArray());
ms.Close();
return retVal;
}
}
|
|
|
|
|
i tried your code but when i assign retVal to mailItem.Body it is filled with content like
"{\rtf1\ansi\ansicpg1252\uc1\htmautsp\deff2{\fonttbl{\f0\fcharset0 Times New Roman;}{\f2\fcharset0 Segoe UI;}{\f3\fcharset0 Calibri;}{\f4\fcharset0 Courier New;}{\f5\fcharset2 Symbol;}{\f6\fcharset0 Arial;}}{\colortbl\red0\green0\blue0;\red255\green255\blue255;\red0\green255\blue255;\red255\green255\blue0;\red31\green73\blue125;\red54\green95\blue145;}\loch\hich\dbch\pard\plain\ltrpar\itap0{\lang1033\fs18\f2\cf0 \cf0\ql{\fs22\f3 {\ltrch Dear Supplier,}\li0\ri0\sa0\sb0\fi0\ql\par}"
|
|
|
|
|
Yup. That's RTF - which is what gets displayed properly when you display rich text format. To test it, take this text and save it in a file that ends with the extension rtf. Then open it up in Wordpad.
|
|
|
|
|
Yes when i open it after giving it rtf extension it shows correct content but what i want to do is create a mail using this content.
|
|
|
|
|
I want to update the display of a TreeView during runtime with new data. All data is stored in a collection which is assigned to the TreeView's ItemsSource.
This works fine first time when the TreeView is empty. But second time it doesn't.
tvTree.ItemsSource = root.Branches;
Later after stored more data in the collection root.Branches
tvTree.ItemsSource = root.Branches;
My XAML code:
<Window x:Class="Tree.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:node="clr-namespace:Tree.TreeNodes"
Title="MainWindow" Height="350" Width="525">
<Grid>
<TreeView Name="tvTree" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="5,5,0,0" Width="400" Height="500">
<TreeView.ItemTemplate>
<HierarchicalDataTemplate ItemsSource="{Binding Branches}" DataType="{x:Type node:Node}">
<Grid>
<TextBlock Text="{Binding Header}" />
</Grid>
</HierarchicalDataTemplate>
</TreeView.ItemTemplate>
</TreeView>
</Grid>
</Window>
The "node" namespace reference, "Branches" in ItemsSource and "Header" in the TextBlock refers to the collection where the data is stored. I guess it's right because the TreeView populates data first time.
Any suggestions?
|
|
|
|
|
Make sure that you bind to an ObservableCollection, and your UI will update based on changes to the collection. This means that you don't have to drop and reassign bindings.
|
|
|
|
|
I don't really get it. I changed the root.Branches from Dictionary<string, branch=""> collection to ObservableCollection<branch> which was not fun. But still nothing happens.
Can you give me small a code example in C# and XAML which works, please?
|
|
|
|
|
Ok, a few clarifications:
1) in your original post you did something like:
treeView.ItemsSource = blah;
and then tried to do:
treeView.ItemsSource = blah;
again later. Not sure if that is a typo or not, but you can't reassign the same list like that because ItemsSource is a dependency property, so the tree view will only respond to CHANGE notifications.
You could do:
treeView.ItemsSource = blah;
treeView.ItemsSource = null;
treeView.ItemsSource = blah;
and it will work, but that is not the right solution.
Pete's response for you to switch over to an ObservableCollection wasn't a great response (and it was incomplete) because as you saw, it took a lot of code changes on your part. It would have been easier to switch you over to ObservableDictionary. This is not part of .NET (yet), but it was published on Dr. WPF's blog several years ago. It is WIDELY used.
2) Switching you over to an observable collection class was only half the solution. That will allow the tree to respond to your adding and removing items, but not changing items themselves. For that, your item class needs to implement INotifyPropertyChanged.
modified on Monday, August 8, 2011 12:40 PM
|
|
|
|
|
I saw the comment typo, darn it. Well you understood it correct
I tried this way:
treeView.ItemsSource = blah;
treeView.ItemsSource = null;
treeView.ItemsSource = blah;
I can see the ItemsSource is changed in debug, but it's already changed before the null is passed into it (I guess that is due to .NET reference mechanism). However the visualization of the TreeView did not change. It's same as when I set ItemsSource the first time.
The root.Branches, which I pass into ItemsSource, is a complex set of classes which is used to store all data that the TreeView should display. I tried with a easier application with a simpler collection of data and then the method works. Very strange!
Any suggestions?
|
|
|
|
|
Created a business application that populates a datagrid form SQL2K8. Using WCF-RIA services. The app works fine. Today I decided to add three more columns to the existing table(used data type varchar(50) and INT ). I updated the SL project as follows:
1. Deleted the XXXDomainServices
2. Deleted the XXXXMetadata
3. Deleted the XXX.edms
4. Recreated the files and compiled the solution
The problem is when I ran the application, the new column names appeared in the datagrid but no data. All the new columns are empty. Looking directly in the SQL2K8 server, the columns are populated with correct values.
Any help is greatly appreciated
|
|
|
|
|
Hi,
what is the best model for using services in a silverlight application?
I usualy add a wcf service to my ASP.net app and add a service refrence to my silverlight application, but anytime I change my service I should update the service refrence in silverlight app.
Is there any better and more proffessional way?
Best wishes
|
|
|
|
|
mehrdadc48 wrote: Is there any better and more proffessional way
I'm gonna be interested in reponses to this one, I see no other alternative to updating the service reference whenever you change the service.
I do take exception to having my method called unprofessional
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
If you can reference an assembly with your service interface and any types you might use. Then you can use the ChannelFactory
ChannelFactory factory = new ChannelFactory<IService>()
IService myService = factory.CreateChannel();
myService.Foo();
the drawback is you don't have any auto generated code so if you need asynchronous calls then you'll have to write that yourself.
If you need the auto generated code, then I suppose you could use svcutil in the post build event of your service project.
eg.
svcutil "http://localhost:1892/IMyService.svc" /out:OutputDir\MyService.cs
This however requires that you have an ISS running with a site that has your service's output directory as it's Content directory.
Also you proporbly have some kind of source control so you might want to add some lines before the above line so that MyService.cs is checked out before svcutil overwrites it.
That's the only two way I know of to avoiding having to update the service reference.
|
|
|
|
|
All this b/c the OP does not like the auto generated code. Not a chance, I have no problem using the auto code, I know what it does, I understand how it works and I have absolutely no interest in circumventing the MS methodology.
The only time I can justify chucking this type of auto generated code is if the code is flaky or it needs to be extended for some reason, so far this has not been the case!
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Mycroft Holmes wrote: I have absolutely no interest in circumventing the MS methodology
I don't see how either of those two methods is circumventing the MS methodology.
When you press Update Service Reference it's svcutil that is being used.
Using the ChannelFactory is what I personally use when I control both the server and the client. My primary reasons for this is; I don't have to update anything(Service reference) and I'm not limited to using DTO's.
While converting a project from using the auto generated proxy to using the ChannelFactory may very well be a waste of time. I do still beleave my other suggestion (using the svcutil) is easy to do and would work.
|
|
|
|
|
I work for a defense contractor, and all of our web sites require smartcards in order to access them. To make matters worse, after a given amount of time of inactivity, the user's PIN must be re-entered before you can continue using the web site. We we were contemplating moving our web sites over to Silverlight4, but we're not sure how to proceed given the smartcard requirement.
I know we can use an aspx web site to allow access to a silverlight app, but the inactivity aspect is not so clear. Has anyone here done a silverlight app in a similar environment (US DoD contractor) that's controlled with a smartcard?
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- "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
|
|
|
|
|
We implement a timeout and log the user off if there is no activity through the navigate method. If some poor bastard needs to sit and stare at a single page for more that 20 minutes then thats just tough, they are out of there.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Hi all,
I need to build TreeViewItems dynamically in Silverlight4, C#.net, Visual Studio 2010 Premium.
Currently the TreeView consists of only a lot of TextBlocks, and I need to put a CheckBox in front of each TextBlock dynamically. This has to be done in code-behind, not in the xaml.
I have done a few Google searches, but could not find anything that I could use to guide me to do this.
Please provide me with links to articles/demos/discussions/etc that will help me.
Some code snippits would be appreciated too...
Thanks
modified on Friday, August 5, 2011 7:45 AM
|
|
|
|