xaml

How do I bind an inherited attached property value to my VM?

I have defined a custom attached property as follows: public class DataFilter { public static readonly DependencyProperty FilterColumnProperty = DependencyProperty.RegisterAttached("FilterColumn", typeof (string), typeof (DataFilter), new FrameworkPropertyMetadata(string.Empty, ...

Is there a xamly way to populate StaticResource at runtime?

I would actually prefer using a DynamicResource in this context, but it's impossible: <Page.Resources> <CollectionViewSource x:Key="CategoriesCollection" Source="{Binding Context.CatsList, Source={x:Static Application.Current}}"/> <DataGridComboBoxColumn Header="Category" ItemsSource="{Binding Source={StaticResource Cate...

The scrollbar of a ListBox disappears in WPF in certain configurations

I have managed to reproduce a weird behavior in the auto scrollviewer functionality of a listbox when it is placed in a 2*2 grid. If you try to use the following xaml as it is you will see that the vertical scrollviewer is there but not visible (it just exceeds the width of the first column) <Window x:Class="WpfApplication1.Window1" ...

What is d:IsOptimized in Expressions Blend?

Just out of curiously, what is d:IsOptimized in Expressions Blend? While I know that d: is a namespace for design-time attributes, does anyone know what d:IsOptimized actually does? Is there anywhere that these Blend-specific attributes are documented? It's not in the design-time attributes supported (and documented) by Visual Studio:...

WPF executable won't run outside of Visual Studio (resource dictionary issue)

I have a WPF app that works beautifully if I "debug" (F5) in Visual Studio (Debug and Release mode both work), but if I try to double-click the .exe in the bin\Release folder, Windows kills the application immediately. The problem appears to be that the executable can't find "PresentationFramework.Aero", which I added to my App's resour...

WPF/Silverlight: Expanding root tree node

Yeah, at first glance this seems basic. But here's the problem: I'm using MVVM and hierarchical data binding to populate the tree. What I'm having a hard time doing is getting the first node to expand. The reasons are: I don't have a direct reference to the tree since I'm in the view-model code. (MVVM is driving me nuts). I've actual...

How to control prefixes of namespaces in XML document generated by XmlWriter - generated XAML with x:Type markup extension

I am trying to generate XAML from XElements. <Style xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"&gt; <Style.BasedOn> <StaticResource> <StaticResource.ResourceKey> <Type xmlns="http://schemas.microsoft.com/winfx/2006/xaml"&gt; <Type.TypeName>p:Window</Type.TypeName> </Type> ...

XAML TreeView Expand Vertically

I would like the TreeView below to expand to fill the current row that it is contained within, however, I can't figure out how this is done. It just expands to fit the tree items. Can this be done, and if so, how? Thanks <Window x:Class="WorkoutUI.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xm...

Why is it necessary to specify the assembly name in a pack URI for WPF resources?

Say I have a project that contains a Window.xaml and ResourceDictionary.xaml. In the Window I pull in via its MergedDictionaries the resource dictionary. If the main app contains both, then I can set Source to simply "ResourceDictionary.xaml". Yet if they are in a DLL assembly, then I must set Source to "/MyLibrary;component/ResourceDi...

Using generic arguments on WPF Window defined in XAML

I'm trying to create a Window-derived class in XAML which can take a generic argument, but I can't seem to define the generic argument in the XAML so that it generates the partial class matching my code-behind file. What I'm trying to accomplish is a replacement for all the MessageBox calls for asking the user questions, where I can giv...

Silverlight XAML vs. Code-behind

From a pure speed perspective of compiled code, does it make a difference if I use 100% XAML or 100% code-behind or some kind of combination in between? There would be no logic in the code-behind like an if statement - it would do exactly the same as what the XAML would do which is to load content elements. If it does make a difference,...

How do you reference the matching object from a DataTemplate in XAML?

I want to use CommandParameter attribute in a context menu associated to a DataTemplate. The commandParameter should contain a reference to the object that triggered the data template as shown in the code sample below. I tried to use "{Binding Path=this}" but it does not work because "this" is not a property. The command fires but I can'...

How can I trigger the PropertyChanged event from static method?

I have the following class public class LanguagingBindingSource : INotifyPropertyChanged { public event PropertyChangedEventHandler PropertyChanged; public string Dummy { get { return String.Empty; } set { PropertyChanged(this, new PropertyChangedEventArgs("Dummy")); } } } that is bound to elements in XA...

In a WPF user control, how do I specify coordinates relative to the control's total size, so that the control will scale correctly?

I have created this simple expand button user control with WPF:          I designed the thing with Width and Height both set to 100 so that I could see what I'm actually doing. The stripped-down XAML of this user control is: <UserControl x:Class="Foobar.ExpandButton" ... Width="100" Height="100"> ... ...

DataTemplate for ItemTemplate of a Grid displaying its content in columns

I have HeaderedItemsControl which ItemsSource is bound to a ObservableCollection<Person>. I would like to display it's content like: *Name* Müller Schmid Weber *FirstName* Peter Hans Willhelm *Age* 32 56 78 *Country* Switzerland Austria Liechtenstein My xaml-Code so far: <Heade...

Why i cant use my custom WPF control in c# code

I am new to this forum. I have a custom user control defined using c# and xaml. When i dag and drop this control to WPF window it works. Even i can edit xaml code tags and insert my control. But when i use my control in c# code, it dont work. here is my xaml control definition <ResourceDictionary xmlns="http://schemas.microsoft.com/...

XAML build error on VB.NET project with controls from external DLL

I'm trying to migrate a WPF Application based on C# to identical project but based writed in VB.NET. I have some problem with XAML Window. The Window have some reference from external dll controls. For example: <Window x:Class="Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas...

How to change default Xaml TextBox fontsize

In my file.xaml, how can I set the TextBlock default size, so that I don't have to include that attribute in the TextBlock element? <UserControl.Resources> <!-- how?/can i set the default font size for textblock element here? --> </UserControl.Resources> <Grid> <StackPanel> <TextBlock Text="{Binding HelloWorld}" /> </S...

AttachedProperty not propagating to children?

Trying to create my own custom AttachedProperty for a WPF DependencyObject failed to actually do what I wanted it to do, and I am a bit worried that I (again) did not understand a WPF concept fully. I made a very simple test class to show where my problem lies. From the MSDN Documentation, I copied public class TestBox : TextBox { ...

Siliverlight databound combobox doesn't display initialized value

I am databinding a view to a viewmodel and am having trouble initializing a combobox to a default value. A simplification of the class I'm using in the binding is public class LanguageDetails { public string Code { get; set; } public string Name { get; set; } public string EnglishName { get; set; } public string DisplayName {...