wpf

[WPF] Styling not applied to dynamically added TextBlock content

I'm trying to add inlines to a text block using the code below. The text block's window uses a Themes.xaml file for styling, but when I add the runs dynamically, the styling does not get applied. Can you help me understand why? foreach (string key in wrappingOptions.Keys) { Hyperlink link = new Hyperlink(new Run(key)); string s = ne...

How do I stop these stupid buttons from moving???

I have these buttons that contain images right, that have a drop-shadow effect, the opacity of which varies, depending on whether you are mousing over them or not. I have these buttons inside a wrap panel (and in one case, a stack panel). Now, (only on my home computer, not my laptop!), if I hover over a button that is not on the end o...

How to search a text of xps document in xps document viewer through code?

Hi, is there any way to search a text through code and bring the focus. This is to bring focus on heading in a xpsDocument. Thanks, ...

How to mimick the behaviour of an ObservableCollection for a List when it is a Source for a CollectionViewSource?

The code below works as follows: a form is shown with a list of sorted names. When the button is clicked a new name is added to the list at the appropriate sorted position from the textbox . When an item of the list is doubleclicked it is prefixed with "AAA", which triggers it to be placed on top of the list. When I change the Observable...

MVVM Mediator multiple instances

Can someone explain how the mediator pattern works with multiple instances. My code in the view: public MyView() { Mediator.Register("CloseWindow",()=>Close()); } and in the ViewModel: public SomeMethod() { Mediator.Notify("CloseWindow"); } This works find as long as there is only one instance of the View - ViewModel pair....

Is there a way to set System.Windows.Controls.SplashScreen to a System.Windows.Window

Hello folks! I was wondering if I can set the splash screen to a programmatic SplashScreen instead of having to do it thru an image. Any ideas? Best regards ...

MyComputer as initial directory

Hi, Is there a way for a open file dialog to use the "My Computer" instead of a specific path. In this example, the W: drive is the intial directory. Dim dlgOpen As New Microsoft.Win32.OpenFileDialog dlgOpen.Filter = "Bases de données Access(*.mdb)|*.mdb" dlgOpen.InitialDirectory = "W:" I figure there must be a value...

Underlining 3 words at a time in WPF

In WPF, how would I do the following: Every x milliseconds, underline 3 words at a time. After x milliseconds, underline the next 3 words. Every x milliseconds, have 3 words appear and disappear from the window? If I were to use Windows Forms, is there still a way of doing (1) and (2) above? Thank you ...

WPF Keyboard Modifier on MouseBinding

I'm working with the MVVM pattern in WPF (a bit new to both). I'd like to set up an InputBinding on a CheckBox that corresponds to a Control + Click event, but do not see a Modifiers property on the MouseBinding element. This is what I'd like to achieve (fictitious code, obviously- Modifiers doesn't exist): <CheckBox> <CheckBox.In...

Improving WPF RichTextBox Language Support?

After a bit of digging it would appear that the WPF built in spell checker only supports English, Spanish, French, and German - which beggars belief somewhat. I can understand they can't really ship comprehensive spell checkers for every language with WPF, but I'd at least expect it to be able to use the Office ones if they are installed...

Bind Image.Source according to Boolean without a converter?

Hi I want to have an image bound to a boolean and have the source of the image to depend on the boolean value i.e. true source="image1" false source="image2" I was wondering if there is a way to do it inline without need for a converter. ...

WPF MVVM dialog example

Does anyone have any examples of showing a window dialog using MVVM (Prism)? - for example a configuration settings window when a command is executed. All of the examples I've seen use the mediator pattern which is fine, but they also all have a reference to the view in the view model which is not ideal (we're using DataTemplates) Than...

Creating a Canvas Background Dynamically

I currently have a canvas which contains a bunch of sqaures as its children. These sqaures sit on different lines. I would like to draw a background for the canvas which draws lines (like a notepad would have feint blue lines on the paper) I would like to draw this dynamically by binding it to a collection of "lines" So if there are 2 ...

C#: What is the value added by commanding?

When looking into MVC frameworks for flex, as3, silverlight, and wpf... a common concept of ICommand / commanding keeps appearing... Can anyone explain the advantage of using ICommand / Execute() ? Where I dont see the value added is - Why can't the controller map the input (ie: a click event) to the correct method inside of the model? ...

Sending data from view to viewmodel with command binding

Question: How do send data to a view model when using command binding? So that, for example, when i click a button, it sends the "currently selected index" of a list so that it can perform an operation on that item of the list Further Information: I'm working on a program where i have a list of shipments, and each shipment has a li...

WPF Animation "Cannot freeze this Storyboard timeline tree for use across threads"

I currently have a listbox that has its selected item bound to a property on my ViewModel. Whenever the selected item isn't null I want to perform an animation on it. However I keep getting the following error "Cannot freeze this Storyboard timeline tree for use across threads" and from research sort of understand why this is happenin...

Manage localization with Baml

Hi guys, I'm developping a little application in WPF and I want to localize my resources. I've always used resources files (.resx), but I heard about BAML that was suppose to change the way of manage localization in a WPF application. I made my research and I found a way to translate my application using those files. I wrote a blog ...

WPF TemplateBinding with custom class

Hi, I have a custom class that extends "Control" like so: class TheCountry : Control { //...details } Then I have that element in my XAML: <Canvas x:Name="mainCanvas" Height="768" Width="1536" AllowDrop="False"> <spots:TheCountry Country="Australia" Canvas.Left="1362" Canvas.Top="486" Template="{DynamicResource TheCountr...

PropertyChangedEventHandler is null when setting property

<UserControl xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:myapp="clr-namespace:MyPlayer.Model" mc:Ign...

WPF app builds in vs2k8, but not on command line w/ msbuild

I have a fairly small solution that includes a WPF windows application. It builds perfectly fine when built from the solution. I recently integrated the projects contained within the solution into an existing, much larger command line build that uses MSBuild. When built from the command line, however, I get the following errors: MainWin...