controltemplate

How can code find resource in model that does not have access to user control

空扰寡人 提交于 2019-12-25 02:50:11
问题 I have a UserControl that has MergedDictionaries : <UserControl.Resources> <ResourceDictionary> <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="../LimitResources.xaml" /> <ResourceDictionary Source="../MenuItemTemplateResources.xaml" /> </ResourceDictionary.MergedDictionaries> ... </UserControl.Resources> in my Model a Menu is created. I want to access ControlTemplate declared in MenuItemTemplateResources.xaml. The ControlTemplate looks like this <ControlTemplate x:Key=

WPF ControlTemplate Trigger with animation

☆樱花仙子☆ 提交于 2019-12-24 11:21:01
问题 I have below code which gives me an error: 'meBorder' name cannot be found in the name scope of 'System.Windows.Controls.ControlTemplate'. <Border Height="20" x:Name="meBorder" Margin="0,200,0,0" Grid.Row="0" Background="Red"> <Button x:Name="btn1" Height="125" Width="30" Content="Dipsa" VerticalAlignment="Top"> <Button.Style> <Style TargetType="{x:Type Button}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type Button}"> <Grid> <Border> <ContentPresenter

Having an issue with my TextBox control template

本小妞迷上赌 提交于 2019-12-24 03:34:10
问题 I am working on a simple textBox template, which is just two borders, one with a gradient background. Now, my specific issue is that I want to be able to set the foreground color of the textBox to whatever color I want and have it work correctly. However, I can't seem to get both the disabled foreground and enabled foreground colors to work together. If I set the foreground to red for example, when I disable the textBox, the foreground doesn't get changed to my disabled color. I tried binding

Expander with animation that support all direction

此生再无相见时 提交于 2019-12-22 17:55:26
问题 My Objective: is to create a Custom Expander with Animation on expanding and should support for all the directions. What I tried: I have Implemented a solution with the help of this. I modified it and made it work based on my need. My solution will work with Up and I can able to make it work even with Down Direction. Whats my problem now: I couldn't make it work with all Directions. I tried and failed to make it work on setting ExpanderDirection to Left and Right . Here is my solution:

How to change the CornerRadius of the Combobox WPF

左心房为你撑大大i 提交于 2019-12-22 11:04:03
问题 I want to use a ComboBox with different CornerRadius , how can I change that simply? I've tried with Style and ControlTemplate , but without any success. 回答1: I don't know if this is simple, but creating a ControlTemplate based on the default ComboBox should do the trick. Here is an example: <Style x:Key="ComboBoxTextBoxStyle" TargetType="{x:Type TextBox}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type TextBox}"> <Grid> <Border CornerRadius="5,0,0,5"

Styling a Textblock autogenerated in a ContentPresenter

牧云@^-^@ 提交于 2019-12-22 07:05:15
问题 As I saw, a lot of people ran into this exact problem but I can't understand why my case is not working and it is starting to drive me crazy. Context: I have a DataGrid which is to be colored according to the values of each cell. Hence, I have a dynamic style resolving the actual template to be used for each cell. Backgrounds now work accordingly. New problem: when I have a dark background, I want the font color to be white and the font weight to be bold so the text is correctly readable. And

WPF TextBox.Text with MultiBinding

▼魔方 西西 提交于 2019-12-22 04:43:34
问题 I've got Custom Control with a TextBox in the default Template. The Custom Control has these 2 dependency properties (among others): SelectedValue, NullText (text to appear in the TextBox when nothing is selected and the value is provided) I'd like to set the TextBox.Text with the NullText value when the SelectedValue null is and the NullText not null is. <TextBox.Text> <MultiBinding Converter="{StaticResource myConverter}"> <Binding RelativeSource="TemplatedParent" Path="SelectedValue"/>

WPF Custom Control: TemplateBinding to Image

▼魔方 西西 提交于 2019-12-21 11:14:23
问题 I am creating a WPF custom control, a Button with an Image and Text . I have added two dependency properties to the control, ImagePath and Text , and the control template (in Themes\Generic.xaml) is a simple stack panel that arranges the image and text horizontally. The Text property works fine. But for some reason, the sample image in my test project doesn't appear when I use TemplateBinding to the ImagePath dependency property to get its path. I have tested the image by temporarily

In a button's control template, how can I set the color of contained text?

半腔热情 提交于 2019-12-21 08:00:17
问题 Using Silverlight 4 & WPF 4, I'm trying to create a button style that alters the text color of any contained text when the button is mouseover'd. Since I'm trying to make this compatible with both Silverlight & WPF, I'm using the visual state manager: <Style TargetType="{x:Type Button}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="Button"> <Border x:Name="outerBorder" CornerRadius="4" BorderThickness="1" BorderBrush="#FF757679"> <VisualStateManager

Wpf ListBox – change default selected-item style *inside* the ContentPresenter

泄露秘密 提交于 2019-12-20 07:16:17
问题 I have a ListBox in which each item is a StackPanel. The StackPanel consist of an Image and a TextBlock below it: <ListBox.ItemTemplate> <DataTemplate> <StackPanel Margin="10"> <Image> <Image.Source> <BitmapImage UriSource="{Binding Path=ImageFilePath}"/> </Image.Source> </Image> <TextBlock Text="Title" TextAlignment="Center"/> </StackPanel> </DataTemplate> </ListBox.ItemTemplate> It looks like this: When the user select an item, I get the default blue rectangle that surround the StackPanel: