staticresource

How can I instantiate WPF elements via their type when they have StaticResources?

I need to instantiate WPF types (say, a UserControl or a Page) via reflection for a designer. The problem I'm having is that when I attempt to instantiate these using Activator.CreateInstance I get a TargetInvocationException which wraps, in the end, an exception thrown by the StaticResource markup extension. Clarification: The types ...

Trying to use a ResourceDictionary, but styles in it come up as not found

I have a Silverlight class library, called MyClassLibrary. In it, I have a user control, called MyControl. Within the control I define user resources: <UserControl.Resources> <Style x:Key="ComboBoxStyle" TargetType="ComboBox"> (lots of xaml) </Style> </UserControl.Resources> The control consumes the style like this: ...

Is it possible to supply a type converter for a static resource in WPF?

I have a newbie WPF question. Imagine my user control has a namespace declaration like this: xmlns:system="clr-namespace:System;assembly=mscorlib" And I have resources for the user control like this: <UserControl.Resources> <system:Int32 x:Key="Today">32</system:Int32> </UserControl.Resources> And then somewhere in my user cont...

WPF StaticResource - The resource could not be resolved (VS 2010 RC)

I've got WPF 4 app that has a number of UserControls that share styles in their child controls. So I'm creating a number of styles in my App.xaml as . For example: <Style x:Key="ViewTitle" TargetType="{x:Type Border}"> <Setter Property="BorderBrush" Value="LightGray" /> <Setter Property="HorizontalAlignment" Value="S...

WPF - ListBox ignores Style When ItemsSource is bound

Hi, I have created styled a ListBox in WPF so that it is rendered as a checkbox list. When I populate the ListBox's items manually, the styling works perfectly. However, when I instead bind the ItemsSource of the ListBox to a static resource (an ItemsControl containing the required items), the styling is completely dropped. Here's the...

how do you set a property of a control to an address of a function in xaml?

Hi, I have a control that has a "Filter" property that expects a function that defines how the contents of the control should be filtered. so far i am setting the filter in code behind as such: MyControl.Filter = AddressOf Filters.MyFilter In this example MyFilter is a shared function in the Filters class with the following signatur...

WPF DataGrid: Resource per row?

Is there a way to xamly set a StaticResource per row in a DataGrid accessing it from all the columns? UPDATE My aim is to have 3 ComboBox columns, while only the last one is actually bound to the rows item. For instance, the DataGrid represents a list of Items. I have Category->Vendor->Style->Finish ComboBoxes, but those are only for ...

Custom button with property as StaticResource

I am trying to achieve the following thing: use an svg image into a custom button. In order to do this I created a Custom button: public class MainButton : Button { static MainButton() { DefaultStyleKeyProperty.OverrideMetadata(typeof(MainButton), new FrameworkPropertyMetadata(typeof(MainButton))); } pu...

Will the changes of a property in a "StaticResource instance" reflected in UI ?

I have used object data provider to create instance of my view-model as below: <ObjectDataProvider x:Key="Datas" ObjectType="{x:Type ViewModel:UserControlViewModel}"> </ObjectDataProvider> <DataTemplate x:Key="SourceGrid"> <WPFToolKit:DataGrid x:Name="SourceDataGrid" ItemsSource="{Binding Source={StaticResource Datas},Path=SourceGridDa...

WPF Compact this XAML which assigns static string to binding

There may not be any practical use of what I want to do, but just to satisfy my curiosity can we compact the 2nd binding in the following XAML into 1 line <TextBlock> <TextBlock.Text> <MultiBinding Converter="{StaticResource MyConverter}"> <Binding Source="{StaticResource One}"></Binding> <Binding> ...

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...

Modify Silverlight Resource in VisualState

I am wondering if there is an easy way to modify some kind of shared resource (i.e. a Brush) of a control between different VisualStates. For example, I would like to define a Brush to use as both the Background of a Border and the Fill of a different Rectangle. In a different VisualState I would like to change this background Brush in o...

override style ignored by Generic.xaml

My generic.xaml code in the Assembly1: <Style x:Key="myLabelStyle" TargetType="{x:Type Label}"> <Setter Property="Foreground" Value="Red"/> <Setter Property="Content" Value="generic"/> </Style> <ControlTemplate x:Key="theButton" TargetType="{x:Type local:MyButton}"> <Grid Background="Beige"> <ContentPresenter/> ...

How to reference a static resource from the current component resources ?

Hello, here is a demonstration of the problem : from a simple window : <Window x:Class="TestWpfStaticResource.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="350" Width="525"> <TextBlock Text="{StaticResource Tes...

In WPF how do I reference a static resource that is defined in a different XAML file?

In WPF how do I reference a static resource that is defined in a different XAML file? It's in the same project. ...

Using system types in XAML as resources

I have encountered a situation where it would be very useful to specify a floating point value directly in XAML and use it as a resource for several of my UI pieces. After searching around I found a good amount of information on how to include the proper assembly (mscorlib) in your XAML so you can do just that. Unfortunately, I am gett...

replace "DynamicResource" with "StaticResource"

Hi everyone! To realize my application I have used a lot Blend3. When Blend3 wants to link a resource to another resource, it uses many times the link-type "DynamicResource". As I have understood (but I could have understood not well), the "Dynamic" links have sense only if I want to modify the links at runtime. In other cases they use m...