staticresource

Is there a significant performance cost to DynamicResource instead of StaticResource?

♀尐吖头ヾ 提交于 2019-11-28 23:21:15
Our designer is using Blend to style our WPF application. When he chooses local resources for properties, Blend will apply them as a {DynamicResource} instead of a {StaticResource} . My guess is that Blend does this because it enables the app to be re-themed at runtime without having to restart it. My question is: is there a significant performance cost to this additional lookup? Should we ask the designer to go back and manually change those Dynamics to Statics? Here is a great SO question that explains the difference between the types: What's the difference between StaticResource and

The resource could not be resolved (VS 2010 RC)

岁酱吖の 提交于 2019-11-28 11:28:35
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="Stretch" /> <Setter Property="VerticalAlignment" Value="Top" /> </Style> Then in my UserControls I use StaticResource to reference them, for example: <Border Style="{StaticResource ViewTitle}"> <TextBlock Margin="6,3,4,5" FontSize="18" FontWeight="Bold" Foreground="White"

Reference custom resource defined in another xaml file

。_饼干妹妹 提交于 2019-11-28 06:28:40
I am trying to create a new resource in one xaml file and reference it in another xaml file. i.e I define <Window.Resources> <ImageBrush x:Key="TileBrush" TileMode="Tile" ViewportUnits="Absolute" Viewport="0 0 32 32" ImageSource="MyImageButton.png" Opacity="0.3"> </ImageBrush> </Window.Resources> And attempt to use it in another xaml file by <Grid> <Button Background="{StaticResource TileBrush}" Margin="5" Padding="5" FontWeight="Bold" FontSize="14"> A Tiled Button </Button> </Grid> However I get the error "StaticResource reference 'TileBrush' was not found." I can reference the resource from

Why the StaticResource cannot be resolved in this case?

余生颓废 提交于 2019-11-27 23:21:55
问题 I have got an exception "Cannot find resource named 'mrg'. Resource names are case sensitive." when I try to do the following: MainWindow.xaml: <Window.Resources> <Thickness Left="0" Right="1" Bottom="2" Top="3" x:Key="mrg" /> </Window.Resources> <Grid> <ItemsControl ItemsSource="{Binding}"> <ItemsControl.ItemTemplate> <DataTemplate> <local:UserControl1 /> </DataTemplate> </ItemsControl.ItemTemplate> </ItemsControl> </Grid> MainWindow.xaml.cs: public partial class MainWindow : Window { public

How to bind to a StaticResource with a Converter?

我的未来我决定 提交于 2019-11-27 21:35:18
问题 I want to use a Converter to change the value of a StaticResource before assigning it to a property. Is there a way to simulate a Binding that will just set the value of the StaticResource after converting it? Something like {Binding Value={StaticResource myStatic}, Converter={StaticResource myConverter}} ? 回答1: This works: <TextBox Text="{Binding Source={StaticResource myStatic}, Converter={StaticResource myConverter}, Mode=OneWay}" /> Note that you have to bind one way, because the binding

MergedDictionaries and Resource lookup

痞子三分冷 提交于 2019-11-27 18:49:30
i have a problem with Resource dictionaries and mergeddictionaries in general, especially when it comes to resource-lookup performance. After some performance testing i found that ResourceDictionary.get_MergedDictionaries is the call with the most hits (checked in ANTS profiler). We have around ~300 resource dictionary xamls, and a lot of them are using merged dictionary to "include" other styles. Well the get_MergedDictionaries count on one part of our application, where not much is happening, was around 10 million hits. So my guess is we are doing something completely wrong with Resource

The resource could not be resolved (VS 2010 RC)

久未见 提交于 2019-11-27 06:16:21
问题 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="Stretch" /> <Setter Property="VerticalAlignment" Value="Top" /> </Style> Then in my UserControls I use StaticResource to reference them, for example: <Border Style="{StaticResource

Reference custom resource defined in another xaml file

萝らか妹 提交于 2019-11-27 05:41:04
问题 I am trying to create a new resource in one xaml file and reference it in another xaml file. i.e I define <Window.Resources> <ImageBrush x:Key="TileBrush" TileMode="Tile" ViewportUnits="Absolute" Viewport="0 0 32 32" ImageSource="MyImageButton.png" Opacity="0.3"> </ImageBrush> </Window.Resources> And attempt to use it in another xaml file by <Grid> <Button Background="{StaticResource TileBrush}" Margin="5" Padding="5" FontWeight="Bold" FontSize="14"> A Tiled Button </Button> </Grid> However I