wpf

Bind WPF TextBlock to text file

How can I bind a WPF TextBlock to a text file? I want for the TextBlock to display the content of the file. ...

When I create click events for my Menu, I end up having about 20 events for each MenuItem. Is this the prefered way?

I'm using WPF Menu. I have about 20 different menu buttons and in my XAML code I associate a Click event to each menu item. Is this the preferred way? ...

How can I remove the borders/control box from a WPF Form?

In Windows Form, I would modify the FormBorderStyle property in the Properties pane. Any help? ...

Target x button of a window title to an Button.Click event handler?

Hello, I have in my window a button called btnExit which I handle its event. I want that when I click the exit button (the red X in the right side) of the form, the event should be handled by the btnExit event. Is this possible whithout need to use the OnExit or Closing etc.? ...

Is using an Enum the best way to go for listing different "Types of Car".

I have an attribute in my car class called VehicleType. Using an enum, I could list the different types of cars that exist and not allow any other type to be hard written in. Problem is, if I have to GET the attribute from somewhere else, I will GET a numberical value, and not the string literal I saved. What should I use here? class...

WPF ListView databinding to ObservableCollection

In WPF app I have a ListView: <ListView Height="100" Width="434" x:Name="lvItems" ItemsSource="{Binding ElementName=MainWindow, Path=ShowQuCollection}" > <ListView.View> <GridView> <GridViewColumn Header="Date" Width="100" DisplayMemberBinding="{Binding Date}"/> <GridViewColumn Header="Time" Width="100" DisplayMemberBinding="{B...

WPF: Minimizing code-behind on the user interface.

I've been playing with WPF/XAML again and have noticed that there doesn't seem to be an easy way to code UI-only keygestures/mousegestures and the like. For example, how to add a "Maximize without windowframe" command to a window. Currently this involves code not unlike this in code-behind: public partial class MainWindow : Window { ...

How can I filter different things according to a class attribute?

Here's the gist of what I'm going to do. Heres' my hero class: namespace TomeOfNewerth_WPF_ { public enum HeroType { Agility, Strength, Intelligence } public enum AttackType { Melee, Ranged, } class Hero { public string Faction; public string Name...

MVVM + WPF + Popup = clueless

I'm still working on modifying my existing WPF application to be "compliant" with the MVVM approach. I'm getting pretty darned close, but am not sure how to solve one of remaining few hurdles. I have a GUI element (currently a button, though it could be a label), where when the mouse enters it, it fires the MouseEnter event, and this c...

WPF ComboBox DropDown part appears in the wrong place

I put several ComboBoxes on a XAML window. When I expand any of them, the DropDown part appears on the upper left corner of the screen. I use Visual Studio 2008 C# Express. I don't remember this phenomenon when I used Visual Studio 2008 (Trial Version), though I use the same FrameWork (3.5). ...

Tray application with hidden icons area problem

I have a tray application in WPF and the problem I have comes up at a closer inspection of the context menu behavior. I am running on Windows 7 with Aero theme checked and while everything seems fine I noticed that the application tends to go to the hidden icons area from the windows taskbar. The problem I have is after I open the hidden...

PresentationFontCache.exe using 99% cpu after starting a WPF app

It happens on my father's machine that a service starts in the background, named PresentationFontCache.exe, as soon as my WPF app loads up. That process hogs 99% percent of the cpu constantly. As far as I know, PresentationFontCache.exe is a part of the .net framework 3.0. ...

Scroll to WPF elements outside boundary

I'm editing a WPF Window object in Visual Studio and have a canvas element that stretches outside the boundary of the Window. Visual Studio only gives a zoom in/out feature, but I can't scroll left or right, even though my canvas inside the Window stretches way off the right of the screen. How can I scroll out all that way? Thanks, Dave...

WPF 3D Hollow Cube With Painted Edges

Hello, I'm am trying to draw a cube which only the edges are shown. I followed this example: http://stuff.seans.com/2008/08/13/drawing-a-cube-in-wpf/ but I couldn't modify it to create a transparent cube with painted edges. Any ideas how to do so? Thanks, Ronny ...

How to implement a TypeConverter for a type and property I don't own?

This is annoying: <GeometryDrawing> <GeometryDrawing.Pen> <Pen Brush="Black"/> </GeometryDrawing.Pen> </GeometryDrawing> I want this: <GeometryDrawing Pen="Black"/> So I write a TypeConverter: public class PenConverter : TypeConverter { static readonly BrushConverter brushConverter = new BrushConverter(); ...

How to change the stroke style ?

Hi, Consider this code: Ellipse myCircle = new Ellipse(); myCircle.Width = 400; myCircle.Height = 400; myCircle.Stroke = Brushes.PeachPuff; myCircle.StrokeThickness = 25; myCircle.ToolTip = "Bold Circle"; Canvas.SetTop(myCircle, 0); Canvas.SetLeft(myCircle, 0); canvas.Children.Add(myCircle); Ellipse myCircle2 = new Ellipse(); myCircle...

WPF FlowDocument: force calculation of height etc. "off screen"

My target: a DocumentPaginator which takes a FlowDocument with a table, which splits the table to fit the pagesize and repeat the header/footer (special tagged TableRowGroups) on every page. For splitting the table I have to know the heights of its rows. While building the FlowDocument-table by code, the height/width of the TableRows a...

Drag & Drop Shapes on Canvas

Hi, I put several shapes (like Ellipse and Rectangle) on a Canvas. Now, I want user to be able to drag & drop these shapes. Is there some predefined functionality that I can use, or I should implement the drag & drop myself using the mouse events ? Thanks ! ...

WPf Datepicker Input modification

I am creating a form using wpf/c#. I am looking to programatically change/interpret the user's typed input in the wpf toolkit DatePicker. For example, the user types "Today", and when the control looses focus the date is interpreted and set to the current date using my c# function. Should I listen to the lostFocus event or is there a...

WPF custom control objects databinding to List(T) based on query

In a window of my WPF application I have several hundreds of objects, they based on a custom control. They differ from each other only by name: ... <MyNamespace:MyCustControl x:Name="x4y3" /> <MyNamespace:MyCustControl x:Name="x4y4" /> <MyNamespace:MyCustControl x:Name="x4y5" /> <MyNamespace:MyCustControl x:Name="x4y6" /> <MyNamespace:M...