wpf

How built-in WPF controls manage their event handlers to an attached event ?

I know that when you register an object to the mouse's attached events, you have memory leaks. That's why you need to use WeakEvent pattern. I have a problem with this pattern : If you want to use it, you cannot define your handler in the XAML code. To me, it means that every code like this leaks : <SomeControl Mouse.MouseDown="MyHand...

DependencyProperty Strangeness

I've put together a WPF application using ObservableCollection and Dependency Properties which is cool because I just have to add an item to the Observable Collection and it shows up automatically, e.g. I display the objects in the collection as boxes on the screen in a wrappanel, each box showing its "Title". So then I wanted to have e...

How do I pass a specific viewmodel object in a button's CommandParam?

I have a simple WPF program using the Master-Detail UI pattern, where the Detail shows the currently selected item of a collection in the Master pane. I'm using MVVM, and each XAML page is backed by a ViewModel object which is set as it's DataContext. Now, I want to add a DELETE button in the Master pane to delete from the master list ...

WPF: How to make empty TextBlock not to occupy space?

Let's say I have a simple layout like this: <StackPanel> <TextBlock Text="{Binding Path=Title}" /> <TextBlock Text="{Binding Path=ShortDescription}" /> <TextBlock Text="{Binding Path=LongDescription}" /> </StackPanel> Now when I have ShortDescription set to null or empty string there's still a gap in place of second TextBlock. I...

Binding Datetime types on Listview (WPF)

Hi there im using C# 3.5, this could be possible ? <EditItemTemplate> <asp:TextBox ID="TextBox4" runat="server" Text='<%# Bind("date", "{dd/MM/YYYY}") %>'></asp:TextBox></EditItemTemplate> <ItemTemplate> I was trying : <ListView Margin="0,80,0,38" Name="dls...

Creating complex source code editing control in WPF

I am wondering if anyone has any experience in creating a new control based on a WPF text box that could support syntax highlighting, line numbers, etc. Any links or advice on how i could begin creating something like this would be very helpful. ...

WPF: Disable ListBox, but enable scrolling

Been banging my head against this all morning. Basically, I have a listbox, and I want to keep people from changing the selection during a long running process, but allow them to still scroll. Solution: All the answers were good, I went with swallowing mouse events since that was the most straight forward. I wired PreviewMouseDown and...

WPF Custom TextBox

Hi im making a custom Textbox i got everty thing working but how do i change the color of the I that blinks when a textbox has focus? ps the the text is inside a ScrollViewer with the property x:Name="PART_ContentHost" Ps this is my first wpf application so im not so good yet... Image ...

WPF Edit Resource

Hi is there any way to change a Resource brush from code or via some binding? what I want to do is change the color of my "main" brush when a button is clicked. Thanks a lot! Edit: Its a GradientBrush how do i change the colors on that? myBrush.GradientStops[0].Color = Colors.Red; just gives me a exception... and is there any way ...

How can I pass multiple parameters to a params array in a WPF MarkupExtension?

I need to create a MarkupExtension for my WPF application that will need to be able to take an arbitrary number of parameters that will be used for token replacement in internationalized strings. Our internationalization code uses a params array to take these parameters. Since I want these to be passable from XAML, is there a way to sp...

Setting Properties of Control Templates in XAML

I've created a button control template where I want to change the glow color of the button on the xaml level. Here is what I mean. <Button x:Name="btnClose" Template="{DynamicResource GlassButton}" Width="32" Height="32" GlowStartColor="Red" GlowEndColor="DarkRed">Button1</Button> The GlowStartColor and GlowEndColor are the propertie...

Why does a WPF BitmapImage object not download an image from a Uri Source in ASP.Net Web Forms?

I'm trying to accomplish the following in ASP.Net: Create a WPF Canvas control Spin up a WPF Image control and a BitmapImage object Set the BitmapImage source to a Uri for an image Add the image to the canvas When the image is downloaded render the canvas to a new bitmap My code works correctly in WPF itself, however when running in ...

WPF: Translating a Canvas at an angle

With reference to this programming game I am currently building. Important: Scroll down to see [Edit] Some of the methods that a user can call in my game will be methods that will do a Translate Transform to the Robot (just a Canvas basically). From the move method, I know the heading (angle) at which the Robot will be facing at the t...

WPF app with transparent windows and remote desktop causing popunders

I have a WPF application with AllowsTransparency="True" because we like funky borders. When I remote desktop into a computer and run our application, menus and right click menus in textboxes are popping up behind the application. I verified this by making the background semi transparent. Here's a screen shot: We're using .net 3.5 SP1...

Changing namespace of the WPF Project Template

When I modify the xaml's cs's I will have to go in and manually modify the corresponding *.g.cs file. And it seems to get overwritten every time I rebuild. So my question is, what is the proper way to change the namespace on a WPF application that has been generated by the WPF project template? ...

WPF Linq to SQL applications Some Best practices using binding and master/detail views

Hi, Well i feel im missing something here because im having problems i bet a bunch of people ran into before and i cant find any solutions to this simple scenario. Application Technology: WPF, 3.5(sp1) framework, LINQ to SQL, o/r designer CRUD, Visual studio 2008, C#. Apllication Layout: Main layout conatins a panel to the left holdi...

How to make a simple hyperlink in XAML?

All I want to do is make a little hyperlink in XAML. I've tried everything. I give up. What is the syntax for this? <StackPanel Width="70" HorizontalAlignment="Center"> <Hyperlink Click="buttonClose_Click" Cursor="Hand" Foreground="#555" Width="31" Margin="0 0 0 15" HorizontalAlignment="Right">Close</Hyperlink...

Render FixedPage contents onto bitmap

I have the following code, taken from http://www.codeplex.com/XPS2Image/ ,which in turn was taken from some people discussing at at Microsoft development forums. int[] pages = new int[] { 0, 1, 2, 3, 4 }; XpsDocument xpsDoc = new XpsDocument(@"c:\tmp\sample.xps", System.IO.FileAccess.Read); FixedDocumentSequence docS...

What is the best way to work with time-driven events in WPF

I have a simple app, that has media element in it, and it plays some movies, one after another. I want to have a 15 seconds delay between one movie stops playing, and the next one starts. I'm new to WPF and though I know how to do this the old (WinForms) way with a Timer and control.Invoke, I thought that there must be a better way in WP...

WPF video tearing on Windows XP

I've created a WPF application using C# that renders about 50 3D elements and animates the camera in order to move around the scene. While it all works, I've noticed as the camera moves, ugly video tearing occurs. I'm well aware of the standard cause of tearing, ie the application is updating frames at a different rate from the monit...