|
Thanks for reply..
I have tried Webbrowser1.source = null;
but its not releasing file.
|
|
|
|
|
Hi
I am looking for a open source project which is a vector editor (like MS Visio)using Silverlight. Any information will be appreciated.
Best regards,
|
|
|
|
|
I have some code written as such:
public override void OnApplyTemplate()
{
base.OnApplyTemplate();
if ((object)Template != null)
{
CheckBox chkBox = Template.FindName("chkBox", this) as CheckBox;
}
}
at runtime, this code works perfectly fine and everything is peachy. Inside of the designer, it apperently fails to find the CheckBox. I'm not really sure why... I can find parts that are in the "standard" template like Border "Bd" and ContentPresenter "PART_Header", but nothing in my overridden template.
Any ideas?
|
|
|
|
|
Hmm... kind of weird, but it seems like triggers aren't executed in the designer or something? I set the template via a trigger. If I hard code the template instead, it does show up... so it seems like my trigger isn't getting executed and its not picking my template.
|
|
|
|
|
OK, first of all have you added the template parts you expect to the class? You'd do this normally like:
[TemplatePart(Name="PART_Box", Type=typeof(CheckBox)] Then, have you set the metadata through the DefaultStyleKey ?
DefaultStyleKeyProperty.OverrideMetadata(typeof(TreeViewEx), new FrameworkPropertyMetadata(typeof(TreeViewEx)));
|
|
|
|
|
Isn't TemplatePartAttribute only used by designers like Expression Blend when you go to style the control? At least, thats my understanding of the attribute.
Anyways, what I was doing was setting the template via a trigger:
<Trigger Property="internal:UIHelper.IsAeroTheme" Value="True">
<Setter Property="Template" Value="{StaticResource AeroTreeViewItemTemplate}" />
</Trigger>
<Trigger Property="internal:UIHelper.IsAeroTheme" Value="False">
<Setter Property="Template" Value="{StaticResource TreeViewItemTemplate}" />
</Trigger>
These triggers get executed at runtime, but they don't seem to get executed at design time, so as far as the designer is concerned, I'm using the standard control template.
I just added this code to my TreeViewItem constructor:
if (DesignerProperties.GetIsInDesignMode(this))
{
if (Internal.UIHelper.GetIsAeroTheme(this))
Template = FindResource("AeroTreeViewItemTemplate") as ControlTemplate;
else
Template = FindResource("TreeViewItemTemplate") as ControlTemplate;
}
and it seems to have solved the problem.
|
|
|
|
|
How can I Changing domain host for silverlight and WCF
|
|
|
|
|
Hello all,
I'm building an app for WP7 (but because my problem seems related to Silverlight/WPF things, I'm asking here). I have a slider wich values are updated every x milliseconds. This leads to unwanted behaviour when the user is dragging the slider to another position. Therefor, I created a new class that inherits from the Slider class, named BusySlider (see below). The problem is now, that my SliderBusy property always seems to be false, even when I'm actually dragging the slider... Any suggestions?
The BusySlider.cs
public class BusySlider : Slider
{
public bool SliderBusy
{
get;
private set;
}
protected override void OnMouseLeftButtonDown(System.Windows.Input.MouseButtonEventArgs e)
{
this.SliderBusy = true;
base.OnMouseLeftButtonDown(e);
}
protected override void OnMouseLeftButtonUp(System.Windows.Input.MouseButtonEventArgs e)
{
base.OnMouseLeftButtonUp(e);
this.SliderBusy = false;
}
}
And here is a frangment of my Dispatcher.BeginInvoke where the slider gets updated;
Dispatcher.BeginInvoke(new Action(delegate()
{
...
if (!slidePosition.SliderBusy)
{
slidePosition.Maximum = (double)state.CurrentTrack.Length;
slidePosition.Value = (double)state.CurrentTrack.Position;
}
}));
Thanks in advance,
MadMatt
|
|
|
|
|
Hello,
I very new to WPF but i have a little experience in MFC.
I am trying to create a simple GUI based app. In MFC when i add new button for example and i go to button properties i can see a list of avaliable events button can send in WPF i cant find such list.
How can i add event handlers to controls beside doing it directly in the XML file?
Thanks!!!
|
|
|
|
|
If you set the Name property of your button then you can use it in your code behind. Eg.:
Xaml:
<Button Name="myButton" Content="Click Me!"/>
Code behind:
myButton.Click += OnMyButtonClick;
I would suggest you look into commands if you haven't done so already.
Sacha Barber has written a good series of articles which introduces the WPF concepts here is a link to the 3rd which covers commands
WPF: A Beginner's guide: Part 3 of n[^]
|
|
|
|
|
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
|
|
|
|