wpf

WPF ScrollViewer with ListBox

Guys, Need your help. I have a ListBox (with virtualization) which displays a ScrollViewer. My ListBox items are expandable, and while expanded their hight may exceed the visible scrolling area. The problem i'm expiriencing is that when the list box item is exceeds the visible scrolling area - scrolling jumps to the next ListBox item ...

Date validation in WPF

I want to validate the date entered in the format dd/mm/yyyy. Using exceptionvalidation I can validate correctly only if the date is entered in the format mm/dd/yyyy. Can anyone suggest some workarounds? ...

WPF, Thumb cursor of GridViewColumnHeader not changed in custom control when resizing ?

Simplely derived from GridViewColumnHeader without styling, class SampleHeader : GridViewColumnHeader {} and use it like: <StackPanel Orientation="Horizontal"> <SampleHeader Content="Col1" /> <SampleHeader Content="Col2" /> </StackPanel> Very simple, but in runtime, the thumb cursor will not change to resizing cursor. I try to ...

Long term operation progress window

Hi, in WPF application I load a list of business objects by WCF to a listbox. I want to load it in another thread and display a progressbar window. But how? I need to call WCF service in the second thread and return its return value to the first (UI) thread. And this is the point I don't know. How to return? Or what should be the corre...

Entity Framework 4 - Sorting by foreign entity

I get "'System.Windows.Data.BindingListCollectionView' view does not support sorting." when I use the following CollectionViewSource: <CollectionViewSource Source="{Binding Path=CourseSessions}" x:Key="cvsCourses"> <CollectionViewSource.SortDescriptions> <ComponentModel:SortDescription PropertyName="StartDate"/> ...

how can i add element host control to winforms Dynamically..??

hi, am using element host for hosting WPF user-control. For that i need elementHost control dynamically, can i add it Dynamically..?? by creating object..?? ...

How to make a WPF TextBox use password characters?

hi, i need to set it it dynamicaliy.. Can i make password Box to as normal text- i mean- user could see the text what he entered.??? its for-> i need to use same control for " password sesion" and also the "item count entering" session ..?? ...

How to add textbox dynamically to WPF usercontrol. .?

How to add textbox dynamically(as per some conditions) to WPF usercontrol. .? WPF usercontrol will be used in Winforms application...! ...

Problem while hash table serialization using datacontract

Hi, I am trying to serialize a hash table using the link XML serialization of hash table(C#3.0) But I am receiving the error as Type 'WpfApplication3.MyHashtable' with data contract name 'AllMyHashtable:http://schemas.datacontract.org/2004/07/WpfApplication3' is not expected. Add any types not known statically to the list of known ty...

How do I know the type of object and cause it?

Paragraph p = new Paragraph(); void Function(var inline) { var r = (inline); string rSer = XamlWriter.Save(r); var inl1 = XamlReader.Parse(rSer); p.Inlines.Add(inl1); // error The best overloaded method match for System.Windows.Documents.InlineCollection.Add(System.Windows.UIElement)' has some invalid arguments } i...

wpf - problem with DragAndDrop between two canvases

Hi I have strange problem with drag and drop operation between two canvases. I wanted to drag my custom control from one canvas to another. I started dragging operation with this code DataObject dragObject = new DataObject("CalendarBlock",block); DragDrop.DoDragDrop(this, dragObject, DragDropEffects.Move); In second ca...

WPF, Xaml and Controls Factory?

I'd like to create WPF control which consists of few another controls. The main problem is how implement choosing right control depending on Model's type? <MyControl> <!-- if DataContext.GetType() == Type1 --> <Control1 DataContext = {Binding}/> <!-- if DataContext.GetType() == Type2 --> <Control2 DataContext = {Binding}> </MyControl> ...

How to make WPF DataGrid scrollbar look like WinForm DataGridView?

I'm trying to migrate to WPF and evaluating the DataGrid. First, I tried to make the DataGrid look and feel similar to the old DataGridView. The problem is that the scrollbars in DataGrid only cover the scrollable area. That means, the column and row header areas are shown in background color, which looks ugly to me. How can I make the s...

Problem for copyn'g from rtf in richtextbox

I have a problem when copying from rtf in richtextbox when serializing lost property. // NOT SERIALIZE properties "bold" and "color" and "size" All code: string ConvertXamlToString(FlowDocument fd) { string format = "@TAG@{0}:{1}@TAG@"; FlowDocument ss = new FlowDocument(); for (int i = 0; i < fd.Blocks.Count; i++) { var block...

wPF VisualTreeHelper.GetParent returns wrong class?

I have the following XAML defined. <Popup x:Class="EMS.Controls.Dictionary.MapTip" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" PopupAnimation="Slide" AllowsTransparency="True" Placement="Mouse" x:Name="root" ...

How to display a downloaded image in WPF window

I need to download a webcam image thru http, and refresh it at 10fps and display it on a WPF window. Right now I'm using this code: Window1 wndMain; BitmapImage img; DispatcherTimer tmrRefresh; public WCam(Window1 wndMain, string imguri) { this.wndMain = wndMain; this.MouseLeftButtonDown += delegate {...

WPF - understanding RoutedEvents

Hi I'm learnign WPF and currently I'm reading about RoutedEvents. In book "Pro WPF in c#" there is some snipet of code which I present below <Window x:Class="RoutedEventsLearning.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Window1" ...

WPF Measure Text inside TextBlock

I have a textblock that contains some text but the text is always going to vary length and I need to render a bitmap out of this textblock. The problem is the textblock doesn't have a height, width, actual height, actual width, or desired size since I set the height and width to Double.NaN so the textblock would auto size. This causes ...

WPF GetWindow casting error

I have a user control hosted inside of another user control. I want the child control to be able to set the "enabled" state of buttons to false (among other things) in the parent. I try GetWindow but am getting the error Cannot convert type 'System.Windows.Window' to 'ucContainer'. Is there an equivalent I could use for a user control...

Display PDF in a BookControl. Convert PDF to XAML?

I've got a PDF I'd like to show in a Book Control. Since this control can't use PDFs I have to work around it by either using images or converting the PDF to XAML. What is the most elegant way to do this? ...