xaml

Styling Hyperlink inside a TextBlock

One of the columns in my DataGrid contains a Hyperlink in a TextBlock. When a row is selected, the hyperlink shows as blue on blue, so i want to change it's text color to white. How can I do that? The DataGrid looks like this: <DataGrid> <DataGrid.Columns> <DataGridTemplateColumn Header="Title"> <DataGridTemplat...

Detect Idle Silverlight Application

What's the simplest way in Silverlight to detect the user is not active? i.e. no mouse input and keyboard input for a period of time. I tried monitoring the mouse events, keyboard events and the focus events of the root visual but it doesn't seem enough. For example, a popup window may be open and these events won't reach the root visua...

Destructive effects for vector drawings in XAML

There are several applications out there that either allow editing vector graphics in some native format and exporting to XAML format or deal directly in XAML but all of which seem to lack in terms of ability to edit drawings through use of destructive effects. What I mean by destructive effects are ones that can be applied to a vector d...

WPF - DataGrid Column with Width="*", but MinWidth to Fit Contents

Hi, What would be the best/right way to have a set of DataGrid columns have proportional width (Width="*"), but to have their MINIMUM width be at least the width of their content? At the moment, if I use Width="*", then the columns stay exactly proportional, but content gets cropped if the columns get too thin. If I use Width="Auto", th...

WPF, display attribute value in TreeView instead of node name

If I have the following data template for a TreeView, what do I need to change so that each TreeViewItem shows the value of the name attribute on each XML node, instead of the node name? <HierarchicalDataTemplate x:Key="NodeTemplate"> <TextBlock x:Name="tb"/> <HierarchicalDataTemplate.ItemsSource> <Binding XPath="child::...

Adding a dynamically changing control in XAML?

I have a class called Loader and inside Loader I have: public class Loader { public static UIElement Background { get; private set; } // ... public void LoadFile(FileInfo file) { // ... } } What this class does, is load a file, either a XAML, MP4, WMV, JPG, or PNG file. The LoadFile() function will take t...

XAML projects (Silverlight / WPF) Images or converted XAML Paths

My teammates and I are discussing the relative merits of converting icons our project uses into XAML. Blend has an "import" option that we can use to convert some of the image resources in the project to XAML Path elements automatically. On the one hand by producing XAML the assembly will remain small. On the other hand there is a simp...

Get control collection from a XAML window

HI all: C# VS 2010 what is the best way to collect the controls Names(X:Name) from a XAML window? Let's say I have textbox,chkbox,datagrid,radio option and so on... I would like to collect the x:Name of each element TIA P.D. I would like to add some security as read-only to some of the textboxes. ...

How to capture the focus of a TextBox inside a ListView grid.

This code generates a Listview with a grid, of multiple name and emails inside TextBox control. I would like to know how can I capture the focus event on one of the TextBox of a row to have the entire ListView row to be selected. <ListView Name="lstRecipients" ItemsSource="{Binding Path=Recipients}"> <ListView.Resources> <Da...

accessing a visual element in code

I would like to do the equivalent of the following xaml in code, but I don't know how to grab that text block element: <local:DayOfTheWeekColumn ... <local:DayOfTheWeekColumn.Header> <TextBlock Text="{Binding ...}, ToolTip="{Binding ...} /> </local:DayOfThe...

XAML button question?

I have this for a hyperlinkbutton: <HyperlinkButton x:Name="Home" NavigateUri="/Home" TargetName="ContentFrame" Content="Home" Style="{StaticResource HyperlinkButtonStyle1}"> Trying to accomplish the same using <Button>, any ideas? ...

Why doesnt WPF border control have a mousedoubleclick event?

Why doesnt WPF border control have a mousedoubleclick event? I have a ItemsControl with some layout stuff in it for a DataTemplate. I want to handle the double click event to pop up a details dialog, but the border, my layout container, doesn't appear to expose the event. Any suggestions on how to either get at the double click event,...

WPF: Getting source of a Binding

I have a reference to a Binding instance, which was defined with an ElementName in XAML. How can I get, at runtime, the actual element instance being the effective Binding's source? The same question holds for bindings with Source, implicit DataContext, etc: how to I get the effective source, given only the Binding instance? And, if ma...

How to reference a specific implementation of a generic type in the DataType attribute of a DataTemplate?

This question is strongly connected to this answer to "How to reference a generic type in the DataType attribute of a HierarchicalDataTemplate?" I followed the basic idea of that answer and created this data structure: <!-- for DictItemVM<string, Remote.Address> which is a viewmodel for a KeyValuePair<...> --> <x:Array Type="{x:Type sy...

How to get WPF controls to size correctly?

I'm just starting out with WPF and I'm trying to layout a UI. I have a StackPanel and within it's bounds I want two listboxes stacked vertically, each covering half of the container panel - regardless of what contents are in them. So far, the listboxes are resizing depending in the items in them, so when they are empty, they don't cove...

Is there a XAML style snippet site?

Are there any decent resources for XAML style snippets? I've not seen too much love on some of the other snippet sites for xaml. Styling might be easier with Blend....but I don't have blend. ...

WPF: Displaying templated objects

This seems basic, but I want to display a representation of some CLR objects that currently exist in a DataContext. I've already set up DataTemplates for how I want them to look, I just want to plop them into the visual space. I tried this, but it doesn't help: <StackPanel> <Binding Path="CalibrationA" /> ...

Collection declared in XAML hangs Silverlight

I have been playing around with declaring objects in XAML. I have these classes in my Silverlight assembly: public class TextItem { public string TheValue { get; set; } } public class TextItemCollection { public ObservableCollection<TextItem> TextItems { get; set; } } Then, I have this in my XAML: <UserControl.Resources> ...

WPF DataGrid MouseOver on DataGridRow

I can't figure out why the first part of code isn't working, but the second is. PART 1 <DataGrid.RowStyle> <Style TargetType="DataGridRow"> <Style.Triggers> <Trigger Property="IsMouseOver" Value="True"> <Setter Property="Background" ...

Overriding code behind layout changes by loading XAML file

I have a WPF app in which my client wants to be able to write a custom xml file to change the default layout set by an existing XAML file. What I am trying to do is fall back to the XAML layout if there are errors in the xml file I am parsing. I have the code behind done for parsing the xml file and changing the default layout but I'm tr...