xaml

How to Programmatically Modify a DataTemplate?

I'm trying to programmatically add events and elements to a DataTemplate in a Silverlight 3.0 app. I have a User Control with a dependency property where I would like to take the template that's set, tweak it, and then set the modified version to an inner control. The idea I have is to take the DataTemplate that comes in, read its XAML,...

CollectionViewSource in CodeBehind with Template Bindings

I'm creating a lookless control based on Selector in WPF with a Dependency Property named "ListItems". When SelectedItems is changed, I do: // CollectionViewSource ListItems = ... ListItems.Source = newSelectedItems; ListItems.Refresh(); And In my control template I bind it to a listbox like this: <ListBox ItemsSource="{TemplateBindi...

WPF: Custom Theme for RibbonControlLibrary

I am using RibbonControlLibrary by Microsoft. It has three predefined themes and one can use them by <ResourceDictionary Source="/RibbonControlsLibrary;component/Themes/Office2007Black.xaml"/> or <ResourceDictionary Source="/RibbonControlsLibrary;component/Themes/Office2007Blue.xaml"/> or <ResourceDictionary Source="/RibbonControlsLibra...

wpf command custom control binding xaml

Hello there, i'm building a Videoplayer custom control (Project called WpfCustomControlLibrary1) and want to add a Load Command. This is what i have added in my class to get this Command: Public Class VideoPlayer Inherits Control ... Public Shared ReadOnly LoadCommad As RoutedUICommand .... Shared Sub New() 'This OverrideMetadata...

Possible to access default styles

Somewhere I read that ExpressionBlend can create copies of the default style of a wpf control for the developer to edit. However, VisualStudio can not. (At least I haven't found a way...) Is it possible to access/view the default styles (and templates) of wpf controls. A Gui would be nice, but a (web)-resource to view the styles would ...

Does anyone know of a XAML-to-CodeBehind converter?

It would be nice to have a tool in which you could copy and paste chunks of XAML such as this: <StackPanel Margin="10"> <TextBlock Text="Title"/> </StackPanel> And the tool would output the equivalent code behind such as this: StackPanel sp = new StackPanel(); sp.Margin = new Thickness(10); TextBlock tb = new TextBlock(); tb.Tex...

How to include an ampersand (&) in the content of a ComboBoxItem

I currently have a Combobox like the following: //XAML <ComboBox> <ComboBoxItem> Awake & Alive</ComboBoxItem> </ComboBox> This raises an error: Entity references or sequences beginning with an ampersand '&' must be terminated with a semicolon ';'. I assume I am missing an escape sequence of some sort to allow me to use a &. How ca...

WPF - Assigning storyboard begintime from parent element

I've got a basic spinner type control I've whipped up, and it works reasonably well, but there's a massive amount of repeated code throughout it. It's essentially the same element over and over again except for two properties, and one of those properties is the BeginTime for the Storyboard - each line just endlessly repeats its animati...

How to bind to a ViewBox in Silverlight?

I have used the ViewBox Silverlight Toolkit control to bind to, however Silverlight 4 add this to the Core, however it no longer has a specific "Content" property to bind to - how to I bind Content to the new ViewBox? For example I want to be able to do this (not valid syntax): <ViewBox Content="{Binding Path=Canvas}"/> Where the C...

How can I bind parent/child ComboBox's against XML datasource?

I have the following XML (simplified example) which should have a parent/child relationship between two ComboBox's. The parent binds correctly but the child does not bind to the parents SelectedItem. When I set xmlns against the foobar XML and remove all namespace references it works as expected. Also if I set ItemsSource="{Binding XPat...

Making URLs on a textblock clickable

Hello, Im programming a little Twitter Client just for fun. I have the tweet's text on a textblock and I want to make the URLs clickable. I know that I have to parse the URLs with a regexp but... how I put text plus link on the textblock? I can't have a string like: Hello check my blog at <Hyperlink>http​://myblogurl.com</Hyperlink> be...

WPF TreeView HierarchicalDataTemplate - binding to object with multiple child collections

I am trying to get a treeview to bind my collection so that all groups show nested groups and each group will show entry. How can I use the HierarchicalDataTemplate so that treeview will process both SubGroups and Entries collection? Groups show subgroups and entries Example: Group1 --Entry --Entry Group2 --Group4 ----Group1 ------Ent...

WPF - Evaluation of Lambdas in XAML

I am writing an app in WPF. It is getting tiresome making all my converters for simple stuff. I looked around and found WPFix. It seems nice, but has not had any releases in almost a year and is looking abandoned. Has anyone used this? Is it stable? Does anyone have any recommendations for a different solution to allow Lambdas in...

XAML - How to get the name of one element in an other view

I have a component which call 2usercontrols. Usercontrols1 :(code part) <StackPanel Name="NeedThisName" > </StackPanel> Usercontrols2 :(code part) <Button > <Button.Template> <ControlTemplate> <Rectangle > <Rectangle.Fill> <VisualBrush Visual="{Binding Elemen...

Common Style for PasswordBox and TextBox

How can I define a common Style for the TextBox and the PasswordBox? My approach, I have define a Style for the TargetType FrameworkElement but this doesnt work as common style, then few propertys doesnt exist on the FrameworkElement. My TextBox Style is equals the PasswordBoxStyle <Style TargetType="{x:Type TextBox}"> <Setter Pro...

XAML - Generic textbox stylewith triggers / parameters?

Hello all I want to be able to have a generic style template that can switch colors of my textboxes based on a bool. But I don't want to have to create a unique style for each textbox. How do I do this? I have put some sample code below how I might expect this to work. Three textboxes, all with different bindings but attempting to use...

Style template does not reevaluate when Data updates

I have a style template (below) that does not update when my Tag binding updates. The data itself updates and I receive no binding errors so expect everything is bound correctly it is just that the style doesn't seem to update at all. I have notifypropertychanged events in all the right places afaik so doubt this is the issue. Thanks ...

Popup vs. Visibility toggle

I have a couple of views that I display as overlays on the main window by binding the visibility to a boolean property in my ViewModel. The main window looks something like this: <Grid> <vw:MainContentView/> <!-- Overlays (normally invisible) --> <vw:NotificationsView/> </Grid> ...

C# WPF - DragMove and click

I need a control to call DragMove() for a Window on MouseLeftButton down, but still function when clicked. If DragMove() is called, Click and MouseLeftButtonUp are not ever fired because DragMove() is a blocking call until they release the mouse button. Does anyone know a workaround to make this work? I have tried this hack based on T...

FlowDocument contents as text

What is the best way to get back the XAML/XML value of a FlowDocument? I noticed there isn't a .Value, .Text, .Caption, .ToXml(), etc... UDPATE: I'd like to be able to get access to it initially to serialize to disk or database. Treat it as its own document format. Later translating it to other formats would be nice. Also been wonder...