wpf

Tiling rectangles seamlessly in WPF

I want to seamlessly tile a bunch of different-colored Rectangles in WPF. That is, I want to put a bunch of rectangles edge-to-edge, and not have gaps between them. If everything is aligned to pixels, this works fine. But I also want to support arbitrary zoom, and ideally, I don't want to use SnapsToDevicePixels (because it would compro...

WPF animation/UI features performance and benchmarking

I'm working on a relatively small proof-of-concept for some line of business stuff with some fancy WPF UI work. Without even going too crazy, I'm already seeing some really poor performance when using a lot of the features that I thought were the main reason to consider WPF for UI building in the first place. I asked a question on here...

Binding a wpf listview to a Dataset....Possible..?

Hi, I was struggling moving to Wpf,I am just stuck while trying out databinding to a lsitview.I want to databind a listview to a dataset(dataset because the data i want to display in columns belongs to different tables).I am attaching a sample code that i am trying with.It works alright but the listliew only shows one row.What could be w...

XAML markup to use DecimalConverter?

I've a Decimal retail price property that I'm binding to a TextBox e.g. Text="{Binding Path=RetailPrice}". By default this displays with all 4 decimal places showing "0.0000". I assume I can use the built in DecimalConverter to shorten this to 2 decimal places "0.00", but can't for the life of me figure out the Xaml markup for this. Or...

Xaml Layout Resources for a Web Guy

Long story short: I've been layout out UI's with Html/CSS for about 8 years now. Recently I've been dipping into Xaml/Silverlight/Wpf and really struggling with designing a UI using Xaml. I understand the basics of the Silverlight Layout Model and feel smi comfortable with using StackPanel and Grids but I'm just not picking it up as fa...

Rotate graphic towards mouse in WPF (like an analog dial)

In WPF/C# how would I rotate a "graphic" to face the current mouse position? Basically what I want is a "wheel" UI Control (like an analog volume dial). I want to be able to click and drag the dial and it will rotate to follow the mouse. Then when I release the mouse it will stop following (obviously!). How would I create one of these?...

Finding the Startup Assembly at Design Time in WPF

I have a WPF MarkupExtension that needs to access resources in the default resource assembly. Extension works fine at runtime, but fails in the designer as the extension can't find the default resources in the startup assembly. In order to load up a ResourceManager I need to know what assembly to load the resources from. At runtime I ca...

WPF ArrangeOverride question

It seems that the final width(or height) passed in to ArrangeOverride method is never less than the desired width (or height) returned from the MeasureOverride method. Is this always true? ...

Images in a WPF Custom Control Library

I need to put an image in the default view of a custom control. However, whenever I try to test the control it can't locate the image. I have tried to compile it as an embedded resource and just a plain resource in VS. Neither of these have worked. So is there a correct way to do this? ...

What is the difference between modifying a control by altering the control template and adding sub controls

Hi, I am new to WPF and I have a doubt in modifying a control. I came to know that one can modify a control by changing its Control Template. i.e., <Button> <Button.Template> <ControlTemplate> ... </ControlTemplate> </Button.Template> </Button> Also we can edit a control utilizing the Content Model. i.e., <Butto...

Select the item in combobox with key/up in WPf

How to select the items in comboxbox using key up/down? I tried to handle it in PreviewKeyDown event. But it is not working. ...

Does MVVM violate DRY?

It seems that ViewModels that I make look suspiciously like other classes and they seem to require a lot of code repetition, e.g. in a current project I have: SmartForm: Model that represents a data form to fill in, has properties: IdCode Title Description collection of SmartFormFields etc. SmartFormControlView View SmartFormControlV...

C#: Creating a graphical screensaver

I am thinking about creating a screen saver. I have the whole thing, its graphics and the back-end kind of ready in my head. But I am not quite sure how to get the graphics out in code. What I would like is a slide show of images with a bit of movement (kind of like the slide show in media center) and some floating text and shapes on to...

Windows Apps: Best Practices & Patterns (C#/WPF/LINQ)

i just graduated from a polytechnic where i was taught quite basic programming (at least in my opinion, like VB Calculators and such) so now in my current job, i feel that that's not enuf. i am wondering from my basic foundation how can i build up my skills? i am picking up C# 3.0 (4.0 seems to be out soon) WPF, LINQ the issue that i f...

How do I bind a StackPanel to my ViewModel?

In my view I have this: <TextBlock Text="{Binding Title}"/> which binds to my ViewModel's Title property and this is straightforward and works well: private string _title; public string Title { get { return _title; } set { _title = value; OnPropertyChanged("Title"); } } However my Vi...

How to put forward a good business case for WPF?

There are many questions about WPF vs Winfoms and the benefits of migrating to wpf, however I have a more specific question, which is probably subjective but would definitely help me justify using WPF. Being in an internal IT department, the business users are not bothered how we get to the end product, but are also not fussed about thi...

How to create an observablecollection class to load images in WPF Application

I have developed a wpf application to load images in listbox.To load 300mb images it is taking time.I heard that to load images faster in listbox we have to use observablecollection,but i dont know how to use that one. Any suggestions plz.. Thanks in advance ...

Should my ViewModel have an ObservableCollection of Views or ViewModels?

I'm trying to understand the basic MVVM design approach when using ItemsControl by binding it via DataTemplates to ObservableCollections on the ViewModel. I've seen examples that bind to ObservableCollections of strings, Views, and ViewModels. Binding to strings seems to be only for demos, it is the binding to "ViewModels that contain ...

How to bubble up changes in my ViewModel hierarchy?

My MainView.xaml contains my SmartForm View: <Grid Margin="10"> <views:SmartForm/> </Grid> the SmartForm view loads an ItemsControl <Grid Margin="10"> <ItemsControl ItemsSource="{Binding DataTypeViews}"/> </Grid> which is an ObservableCollection of DataTypeViews: List<FormField> formFields = new List<FormField>(); ...

How can you get a XAML TextBlock to collapse when it contains no data?

I want to tell WPF: "If TextBlock contains no data, then don't show it." TRY #1 with a simple trigger produces the error "'Text' member is not valid because it does not have a qualifying type name.": <StackPanel Margin="10"> <TextBlock Padding="10" Background="Yellow" Text="{Binding MainMessage}"> <TextBlock.Triggers> ...