xaml

How do you properly test the view in MVVM?

I've seen a few articles on unit testing view models in MVVM and how the tests themselves are consumers of the view models, testing the functionality of the viewModel and model. However, I'm left wondering how I go about testing the views (UI) to ensure they are wired up to my view models properly. I don't want to write a test that, fo...

WPF - ScrollViewer will not scroll when ScrollToHorizontalOffset() is called

I have a Scrollviewer inside a TabControl, and for some reason when you change tabs my ScrollViewer jumps to HorizontalOffset of 12. My ScrollViewer, among other things has a ListView inside it with an unrestricted height. It's a strange layout, but everything inside the scroller had to be printable so I couldn't easily allow the ListV...

WPF Style Trigger on Foreign UIElement

If I have 2 buttons, A and B, is it possible to create a style and trigger such that when the user hovers over button B, it will cause button A's style to change? I've tried using SourceName and TargetName, and am getting compiler errors. Here's the XAML that I'm fooling around with - I'd like to cause button A's content to be bolded w...

XAML Button Invisibility with Command Binding

<Button x:Name="StartButton" Style="{DynamicResource StartTimerButton}" Width="30.75" Margin="10,0.25,6,0" ToolTip="Start Timer" Command="{Binding ExecuteStartStopWatch}" VerticleAlignment="Center" /> <Button x:Name="PauseButton" Visibility="Collapsed" Style="{DynamicResource StartTimerButton}" Width="30.75" Margin="10,...

windows WPF and XAML button changeing

I am trying to make play/pause button. When the Play button is clicked, it will bind to the StartStopWatch command. The play button will then change to a pause button which will bind to the PauseStopWatch command. My problem is. I don't know how to keep the style it has and change them interchangablly. Currently I have two different butt...

WPF: Add Page w/functionality into a Window at runtime as XAML

I have created a WPF app where I dynamicly build XAML elements using c# code and then add them to a root "container" grid. What I'm trying to do is take advantage of the features in Blend and create some XAML Pages that have their own set of code behind logic, Storyboards, etc. I want to load that XAML at runtime, however for some rea...

WPF/XAML: Set a style with a different TargetType?

I have an external style resource in a resource dictionary I'm referencing with x:Key. It has an x:TargetType specifying a target (TextBlock). Is it possible to apply this to a control containing a TextBlock and have all TextBlock elements within that control have the style applied? Thanks, Robert ...

WPF GroupBox ContextMenu now showing unless the border/header clicked

Hi everyone, I've got a scenario where I have a GroupBox which has a bit of content in it. I'm looking to add ContextMenu to that GroupBox and have that menu shown when the user right-clicks anywhere in the box. The problem I have is that the context menu only appears when the border or the header of the group box is clicked. If you cl...

WPF DataTemplate to flatten out XML tree to a list?

Given xml that looks like this: <Root> <Fruittree name="Apple" ID="2"> <Branch name="West" ID="1"> <Fruit name="Foo"> <Fruit name="Bar"> </Branch> </Fruittree> <!-- more fruitrees etc... --> </Root> Using xaml with a XmlDataProvider and a DataTemplate, I want to display a list, perhaps in a listbox: ...

How can i globally set the Culture in a WPF Application?

I would like to set the Culture of a WPF application to a specific one based on user preferences. I can do this for the current thread via Thread.CurrentThread.Current(UI)Culture, but is there any way to do this globally for the application (so it affects all threads by default)? ...

WPF Popup ZOrder

Hi, I am using a WPF Popup, but it popups up above every single window on my desktop, even when my application is minimized. How can I make it stay only on the window it originated? The same thing happens when my window is behind other windows: the popup displays above them all. "There must be something can be done!" Thanks. ...

How do I get a TextBox to only accept numeric input in WPF?

I'm looking to accept digits and the decimal point, but no sign. I've looked at samples using the NumericUpDown control for WinForms, and this sample of a NumericUpDown custom control from Microsoft. But so far it seems like NumericUpDown (supported by WPF or not) is not going to provide the functionality that I want. The way my app i...

Convert XHTML to XAML FlowDocument

Dear All Does anybody invent a workable converter program that can convert XHTML file to FlowDocument xml file? I need this because my XHTML document have nested tag and it make my converter xslt thrown exceptions. any ideas? I appericate all replys and your times. Best regards -Ariso ...

Broken Styles when using XamlReader to parse and insert a FlowDocument into a RichTextBox

I am converting Html to Xaml(FlowDocument to be exact) and use XamlReader to parse the newly created FlowDocument. I then insert my new FlowDocument into the RichTextBox, but none of my Application level Styles get applied to the FLowDocument elements such as the Hyperlinks. An example of one of my styles: <Style TargetType="{x:Type...

Binding to ConfigurationSection

I just converted all my settings from AppSettings to ConfigurationSections. It definitely cleaned things up, but I'm having difficulties with the preferences window. I want to use bindings in my WPF window. Should I store each of the ConfigurationSections in a dependency property and bind to the ConfigurationSection's properties? Sh...

Stretching controls to fill ItemsControl

I am attempting to write a simple WPF learning project which creates a set of buttons inside a resizeable main window. There is to be one Button per entry in a collection, and the contents of that collection may vary during run-time. I want the buttons to fill the entire window (e.g. 1 button @ 100% width, 2 buttons @ 50% width, 3 butt...

How to display treeview inside listview in xaml + C# and MVP

Hi, How to display treeview inside a list view, actually this listview has headers namely workbook, description,date, so when I display the tree view inside the listview, the treeview should open as per the listview headers. My question is : 1. How to insert treeview inside Listview and my xaml code is <ScrollViewer VerticalScrollBar...

How to dynamically change ConverterParameter (or any) property of a MultiBinding (or any other) resource at runtime?

Hi. i'm new to wpf and xaml. i find solutions of most of the problems (in other languages) by searching here n there or googling around but this one made me crazy. i searched a lot on google and browsed many forums, but it seems that this time i met with a real challenge! I have following code in Window.Resources: <my:NameConverter x:K...

Setting a WPF ContextMenu's PlacementTarget property in XAML?

<Button Name="btnFoo" Content="Foo" > <Button.ContextMenu Placement="Bottom" PlacementTarget="btnFoo"> <MenuItem Header="Bar" /> </Button.ContextMenu> </Button> gives me a runtime error 'UIElement' type does not have a public TypeConverter class I also tried <Button Name="btnFoo" Content="Foo" > <Button.ContextMen...

Initialize a WPF combo box in XAML?

Is there a way to set the initial value of a databound combo box in XAML? Here is my combo box: <ComboBox IsSynchronizedWithCurrentItem="True" ItemsSource="{Binding Source={StaticResource NHibernateTypes}}" SelectedValue="{Binding ElementName=IdentifierPoperty, Path=PropertyType}" HorizontalAlignment="Stretch" Ve...