xaml

WPF Resource Dictionary in a separate assembly

I have resource dictionary files (MenuTemplate.xaml, ButtonTemplate.xaml, etc) that I want to use in multiple separate applications. I could add them to the applications' assemblies, but it's better if I compile these resources in one single assembly and have my applications reference it, right? After the resource assembly is built, how...

Aligning content in a WPF Viewbox

I have a Viewbox that is using Stretch=Uniform in order to not distort the content. However... when the frame window is wider or taller than the content, the Viewbox content is always centered. I cannot seem to find any content alignment options on the Viewbox. Is there a way to do this? ...

Creating a DIP Switch control in WPF

In an effort to teach myself more about WPF, I'm trying to build a simple application. Where I work we have some hardware that has a bank of 8 dip switches used for setting an address from 0 to 255 (as an 8-bit number). It's a simple concept that I would like to build into a WPF windows application that would allow users to see the dip s...

Do you have any tips for C# Minification?

I need to minify some C# code in a handful of Silverlight .cs and .xmal files. What are your tips for maintaining one code base and running a "tool" to generate minified code for a project? Are there any tools (like Resharper) that will do this? If not fully, partially or assist in some way... EDIT: I realize that there is no need for ...

Individual Character Padding in XAML

Is there a way in XAML to add padding around individual characters? Preferably before and after the character. I have a textbox that I would like the input to be spaced out a bit more (so it aligns with a background image). It would be ideal to be able to do something like: Any ideas how one can accomplish this? It looks like one c...

AdornerDecorator and tab stop issues

Hi, I am using IDataErrorInfo to validate and indicate errors in my text boxes. I am finding I have to tab once for the text box and once for the adornerdecorator. I have an error template: <ControlTemplate x:Key="ErrorTemplate"> <StackPanel KeyboardNavigation.IsTabStop="False" > <Border KeyboardNavigation.IsTabStop="F...

Converting XAML ObjectDataProvider to C#

I would like to create my ObjectDataProvider in my C# code behind rather than my XAML. I was wondering how to change this XAML into equivalent C#. The XAML was generated by Microsoft Expression Blend 2, so the d: namespace can be ignored safely. <ObjectDataProvider x:Key="FooSourceDS" ObjectType="{x:Type myNS:FooSource}" d:IsDataSource...

Can you bind the selected item in a listbox to a separate object in WPF?

If I have two objects, one being the list of items, and the other having a property storing the selected item of the other list, is it possible to update the selected item through binding in WPF? Lets say I have these two data structures: public class MyDataList { public ObservableCollection<Guid> Data { get; set; } } public class...

WPF DataTrigger where value is NOT null?

I know that I can make a setter that checks to see if a value is NULL and do something. Example: <TextBlock> <TextBlock.Style> <Style> <Style.Triggers> <DataTrigger Binding="{Binding SomeField}" Value="{x:Null}"> <Setter Property="TextBlock.Text" Value="It's NULL Baby!" /> </DataTrigger> </Sty...

C# data binding doesn't update WPF.

I'm trying to do a Data Binding in the C# code behind rather than the XAML. The XAML binding created in Expression Blend 2 to my CLR object works fine. My C# implementation only updates when the application is started after which subsequent changes to the CLR doesn't update my label content. Here's the working XAML binding. First a ...

XAML - StaticResources in Collection Initializers

I want to add a single model object that has been instantiated once in XAML, and add it to two different collections (in xaml). The following code renders fine in Blend's Design Time, but I get the following errors at run time: For "Post1" Object of type 'WpfBlog.Models.Tag' cannot be converted to type 'System.Collections.ObjectModel.O...

Custom UserControl Property used by child element

I'm trying to get some WPF concepts down, so I've put together a simple example of what I'm trying to do. I would like to set a custom property of a user control, and have it be used by an element within the control. I've been researching and experimenting, but I'm not fully understanding everything here. Any help would be appreciated. ...

How do I make WPF ListView items repeat horizontally, like a horizontal scrollbar?

I have a WPF ListView which repeats the data vertically, I cannot figure out how to make it repeat horizontally, like the slideshow view in Windows Explorer. My current ListView definition is; <ListView ItemsSource="{StaticResource MyDataList}" ItemTemplate="{StaticResource ListViewTemplate}"> </ListView> The DataTemplace is (although...

How can I underline a databound value from a DataTemplate?

If I want to display an underlined value in a TextBlock, I have to use a Run element. (If there's a better/easier way, I'd love to hear about it.) <TextBlock> <Run TextDecorations="Underline" Text="MyText" /> </TextBlock> Ideally, to implement this within a DataTemplate, it would look something like this: <DataTemplate x:Key="under...

How to open a WPF Popup when another control is clicked, using XAML markup only?

I've got two controls, a TextBlock and a PopUp. When the user clicks (MouseDown) on the textblock, I want to display the popup. I would think that I could do this with an EventTrigger on the Popup, but I can't use setters in an EventTrigger, I can only start storyboards. I want to do this strictly in XAML, because the two controls are in...

How can I make a Button with multiple content values?

My goal is to make a Button that has two Content values. Imagine a Scrabble tile as a button: it has the large letter in the center and a small number in the lower right. This is the effect I am going for. I made a button that has two ContentPresenter objects in it, and I have given each of the ContentPresenters a different style. ...

accessing http query string in a xaml file

If an http request is made to an asp web page, then the asp code can access the query string via the Request.QueryString object. What's the analagous way to do this in xaml? For example, say that I wanted to write a simple xaml page that just echoes the query string back in the response. What would the code for this look like? ...

Performance comparison of Winforms and WPF

Since XAML gets compiled, there should be no difference in execution of code like this. Winforms (code like): Form formPeter = new Form(); Textbox textbox = new Textbox(); Label l1 = new Label1(); Xaml does not get parsed at runtime, as I thought... :-) But what about rendering/execution of big forms with lot of controls? Which tech...

Xaml FlowDocument table - how to get the header on each page on a multi-page table?

I've got a XAML FlowDocument containing a table with a lot of rows, spanning multiple pages, and I'm converting this FlowDocument to XPS. Now I'm looking for a way to repeat the header of the table on each page. I see two possible approaches: 1) Get the table to automagically print the header on each page. 2) Somehow by program find...

Automatically focusing parts of a ListBoxItem on selection.

I have a ListBox which is populated from a collection of ViewModels, which uses in place editing, which I do by having a couple of styles which I can apply to parts of the DataTemplate which make them visible/collapsed as required. These look something like: <Style x:Key="UnselectedVisibleStyle" TargetType="{x:Type FrameworkElem...