wpf

What is the purpose of Dispatcher CheckAccess?

On Async webservice on complete event, there is a code like belows. Debug.Assert(Dispatcher.CheckAccess()); // don't do marshaling here- it's already runinng on UI thread! Does anybody know what happens if I remove this code? or able answer my questions? ...

Paragraph.BringIntoView() works only when focused

Hi, I am working on a text editor that is based on RichEditBox. I have implemented functionality "Go to line" which eventually resolves to TextPointer.Paragraph.BringIntoView(); Along with this I also set the caret position. What I found out is that BringIntoView only works when I click on the RichEditBox first (focus it). Otherwise it...

Problems with rendering text as bitmaps using WPF

I am developing an application using WPF to dynamically render content, including text and images from WPF into jpg files. I am currently using the RenderTargetBitmap class to do the job. Everything works as expected but the quality of the rendered fonts is terrible. I understand that the RenderTargetBitmap doesn’t use the ClearType but ...

PRISM + Tabs = Pain

I am having difficulty trying to get a very simple scenario working with PRISM 2.0 for WPF. I want the main workarea of my application to be a TabControl. Each time I add a view, I want it to appear as a TabItem on the TabControl. Sounds easy right? My region, which is in my Shell.XAML looks like this: <Controls:TabControl Name="...

Check / Uncheck a ToggleButton From a StoryBoard in WPF

I have an animation that expand / collapse some StackPanels, in the window there are some ToggleButtons that must be unchecked when the StackPanel is collapsed. I have the animation like this: <Storyboard x:Key="cmdUnchecked"> <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="StackPanel1" Storyboard.TargetPro...

C# Button Click Events firing after Command

I am having trouble trying to get a click event to fire after the command gets executed. I am trying to follow the MVVM style of development. Here is the scenario: In my application I have a grid of 2 by N buttons, where N is a dynamically loaded set of buttons (sometimes it'll be 2 x 2, sometimes its 5 x 9, I don't know). Initially, a...

Problems using ListBox and observable collection as a debug log

I have a listbox bound to a view model observable collection: This works fine, minus one little hitch... assuming that the observable collection contains strings, the whole thing breaks down when entries with identical values get added to the collection, what is the best way to handle this? Custom struct instead of strings and then a ...

In WPF, is it possible to have a combo box control, that looks like a RadioButton?

I have a whole bunch of code that is dependent on the ComboBox type, and I want to be able to use it on a new UI, but the UI that I want to use it for needs to look like a RadioButton for usability reasons. Is it possible to have a ComboBox control look like a set of RadioButtons? ...

WPF: Scroll into view a new item in a ItemsControl

I have an ItemsControl that is databound to a ObservableCollection. I have this method in the code behind which adds a new model to the list. I would then like to scroll the new item (at the bottom of the list) into view. I think the size of the ItemsControl is not yet updated when I am querying the size, since the ActualHeight before a...

Listing all Validation.Errors in a single WPF control?

I'm trying to find a simple way of binding a single control (eg. TextBlock or ListBox) to list all the validation errors on a WPF form. Most source code examples I have been able to find just bind a control to (Validation.Errors)[0].ErrorContent which only shows a single validation error. I'm currently using ValidationRule classes, thou...

default button fires on window load.

I have a login window with a "Sign In" button which is set as the default button (IsDefault="True"). The sign in button is supposed to open a new window which also has a default button. When the user hits the enter key, the Sign In button click event is raised and a new window is opened. But, for some reason the click event for the defa...

Repeating databound item in WPF FlowDocument

Hello, I have a flowdocument in WPF that looks like this: <FlowDocument xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"&gt; <Paragraph FontFamily="Georgia"> <StackPanel> <TextBlock Text="{Binding Path=Title}"/> <Tex...

Can I make WPF RadioButtons look like CheckBoxes?

I want to have the behavior of RadioButtons, but show them as CheckBoxes to the user. Is this easy to do? ...

Retain focus on a UI element, but click a button on a different dialog. WPF C#

I am developing a touchscreen friendly app that also includes a virtual keyboard. My virtual keyboard is in its own window, allowing it to be moved around. The problem is that when I click on a key on the keyboard the text box on the main application window no longer has focus. The switch from the main application being the active window...

WPF bind DataContext in xaml to ViewModel in code

Hello, i have this simplified version of my app in XAML: <UserControl xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:uc="clr-namespace:myApp.MyControls" x:Class="myApp.View.MyIte...

How to delete a ListViewItem when bound to a DataView

How do I delete a selected ListViewItem from a WPF ListView when the ItemsSource is set to a DataView? I can get the ListViewItem that was selected and then how do remove the actual row in the DataView? DataView dv = (DataView)myListView.ItemsSource; ListViewItem lvi = (ListViewItem)myListView.ItemContainerGenerator.ContainerFromItem(m...

WPF resources addin

I have a WPF application that runs as an add-in in another application. (In this case it is COM based but I don't think it matters for the problem I have) The application works fine when I run it standalone. When running as add-in there is a problem with resources. First: (minor) The "pack:" uri scheme is not available at all. I can w...

[XAML] Using ObjectDataProvider as binding source gives SQL error

Hi I have a weird problem that i can't figure out a solution for: I've made a little WPF app written in C# that uses an attached SQL Server Express .mdf database which i then manipulates through LINQ. I have a ListView on the form which datacontext is set to .DataContext = dr.FindAllBuyOrders() which returns an IQueryable BuyOrder obj...

Clipping WPF elements in a canvas

I am working on an interactive WPF graph/tree tool and have nodes and links between them placed in a canvas. The nodes are usercontrols and the links are simply Line shapes, and currently the links go from the centre of a node to another node's centre. The problem arise when I want the nodes to be slightly transparent and one sees the l...

WPF How to bind the same event handler to two different controls

I have a UI with a search text box and a button that that should be clicked when the user want to preform the search. (like a search engine UI) I want that the same event handler will be called when the user hit the search button and when the user hit enter in the text box. I can easily hack it but my guess is that WPF has it's own 'r...