Search Results

Search found 238 results on 10 pages for 'controltemplate'.

Page 1/10 | 1 2 3 4 5 6 7 8 9 10  | Next Page >

  • WPF ComboBox Binding breaks when using ControlTemplate

    - by Mitch
    I have a WPF ComboBox that has been working fine until I recently created a ControlTemplate for it to enable me to change the color of the DropDown arrow. The ComboBox still works correctly except the Bound Text value now just shows the name of the Business Object rather than the bound value. I guess that binding like Text="{Binding Path=CaseDateRange}" no longer works when using a ControlTemplate, yet the ItemsSource binding on the dropdown seems to still work fine. Can anyone offer some help with how I need to change my binding when using a ControlTemplate. The code for the ControlTemplate and ComboBox is as follows <ControlTemplate x:Key="ComboBoxControlTemplate1" TargetType="{x:Type ComboBox}"> <Grid x:Name="MainGrid" SnapsToDevicePixels="True"> <Grid.ColumnDefinitions> <ColumnDefinition Width="*"/> <ColumnDefinition MinWidth="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}" Width="0"/> </Grid.ColumnDefinitions> <Popup x:Name="PART_Popup" AllowsTransparency="True" Grid.ColumnSpan="2" IsOpen="{Binding IsDropDownOpen, RelativeSource={RelativeSource TemplatedParent}}" Margin="1" PopupAnimation="{DynamicResource {x:Static SystemParameters.ComboBoxPopupAnimationKey}}" Placement="Bottom" OpacityMask="#FF2A3D64"> <Microsoft_Windows_Themes:SystemDropShadowChrome x:Name="Shdw" Color="Transparent" MaxHeight="{TemplateBinding MaxDropDownHeight}" MinWidth="{Binding ActualWidth, ElementName=MainGrid}"> <Border x:Name="DropDownBorder" BorderBrush="White" BorderThickness="1" CornerRadius="3" Background="{DynamicResource DialogDarkBlue}"> <ScrollViewer x:Name="DropDownScrollViewer" > <Grid RenderOptions.ClearTypeHint="Enabled"> <Canvas HorizontalAlignment="Left" Height="0" VerticalAlignment="Top" Width="0"> <Rectangle x:Name="OpaqueRect" Fill="{Binding Background, ElementName=DropDownBorder}" Height="{Binding ActualHeight, ElementName=DropDownBorder}" Width="{Binding ActualWidth, ElementName=DropDownBorder}"/> </Canvas> <ItemsPresenter x:Name="ItemsPresenter" KeyboardNavigation.DirectionalNavigation="Contained" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/> </Grid> </ScrollViewer> </Border> </Microsoft_Windows_Themes:SystemDropShadowChrome> </Popup> <ToggleButton BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}" Grid.ColumnSpan="2" IsChecked="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" Foreground="White"> <ToggleButton.Style> <Style TargetType="{x:Type ToggleButton}"> <Setter Property="OverridesDefaultStyle" Value="True"/> <Setter Property="IsTabStop" Value="False"/> <Setter Property="Focusable" Value="False"/> <Setter Property="ClickMode" Value="Press"/> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type ToggleButton}"> <Microsoft_Windows_Themes:ButtonChrome x:Name="Chrome" BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}" RenderMouseOver="{TemplateBinding IsMouseOver}" RenderPressed="{TemplateBinding IsPressed}" SnapsToDevicePixels="True"> <Grid HorizontalAlignment="Right" Width="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}"> <Path x:Name="Arrow" Data="M0,0L3.5,4 7,0z" Fill="White" HorizontalAlignment="Center" Margin="3,1,0,0" VerticalAlignment="Center"/> </Grid> </Microsoft_Windows_Themes:ButtonChrome> <ControlTemplate.Triggers> <Trigger Property="IsChecked" Value="True"> <Setter Property="RenderPressed" TargetName="Chrome" Value="True"/> </Trigger> <Trigger Property="IsEnabled" Value="False"> <Setter Property="Fill" TargetName="Arrow" Value="#FFAFAFAF"/> </Trigger> </ControlTemplate.Triggers> </ControlTemplate> </Setter.Value> </Setter> </Style> </ToggleButton.Style> </ToggleButton> <ContentPresenter ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}" Content="{TemplateBinding SelectionBoxItem}" ContentStringFormat="{TemplateBinding SelectionBoxItemStringFormat}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" IsHitTestVisible="False" Margin="{TemplateBinding Padding}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/> </Grid> <ControlTemplate.Triggers> <Trigger Property="HasDropShadow" SourceName="PART_Popup" Value="True"> <Setter Property="Margin" TargetName="Shdw" Value="0,0,5,5"/> <Setter Property="Color" TargetName="Shdw" Value="#71000000"/> </Trigger> <Trigger Property="HasItems" Value="False"> <Setter Property="Height" TargetName="DropDownBorder" Value="95"/> </Trigger> <Trigger Property="IsEnabled" Value="False"> <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/> <Setter Property="Background" Value="#FFF4F4F4"/> </Trigger> <Trigger Property="IsGrouping" Value="True"> <Setter Property="ScrollViewer.CanContentScroll" Value="False"/> </Trigger> <Trigger Property="CanContentScroll" SourceName="DropDownScrollViewer" Value="False"> <Setter Property="Canvas.Top" TargetName="OpaqueRect" Value="{Binding VerticalOffset, ElementName=DropDownScrollViewer}"/> <Setter Property="Canvas.Left" TargetName="OpaqueRect" Value="{Binding HorizontalOffset, ElementName=DropDownScrollViewer}"/> </Trigger> </ControlTemplate.Triggers> </ControlTemplate> And the ComboBox is <ComboBox x:Name="cboSelectedCase" Text="{Binding Path=CaseDateRange}" DisplayMemberPath="CaseDateRange" SelectedValuePath="CaseID" Template="{DynamicResource ComboBoxControlTemplate1}" />

    Read the article

  • Default custom ControlTemplate is not applied when using Style

    - by gehho
    Hi all, I have created a default style for a Button including a custom ControlTemplate like so: <Style TargetType="{x:Type Button}"> <Setter Property="OverridesDefaultStyle" Value="True"/> <Setter Property="Background" Value="White"/> <Setter Property="BorderBrush" Value="Black"/> <!-- ...other property setters... --> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type Button}"> <Grid x:Name="gridMain"> <!-- some content here --> </Grid> </ControlTemplate> </Setter.Value> </Setter> </Style> This style is added to my shared ResourceDictionary which is loaded by every control. Now, this style/template is applied to all my buttons, as expected, but it is NOT applied to those buttons which locally use a different style. For example, I want to have a certain margin for my "OK", "Apply" and "Cancel" buttons. Therefore, I defined the following style: <Style x:Key="OKApplyCancelStyle" TargetType="{x:Type Button}"> <Setter Property="Margin" Value="4,8"/> <Setter Property="Padding" Value="8,6"/> <Setter Property="MinWidth" Value="100"/> <Setter Property="FontSize" Value="16"/> </Style> ...and applied that style to my buttons using a StaticResource: <Button Content="OK" Style="{StaticResource OKApplyCancelStyle}"/> For me, the expected result would be that the ControlTemplate above would still be applied, using the values for Margin, Padding, MinWidth and FontSize from the "OKApplyCancelStyle". But this is not the case. The default Windows ControlTemplate is used instead, using the values from the style. Is this the typical behavior? Does a local style really override a custom ControlTemplate? If so, how can I achieve my desired behavior? I.e. still use my custom ControlTemplate even when styles are defined locally? Many thanks in advance, gehho.

    Read the article

  • Create ControlTemplate programmatically in wpf

    - by Thomas Stock
    Hi, How can I programmatically set a button's template? Polygon buttonPolygon = new Polygon(); buttonPolygon.Points = buttonPointCollection; buttonPolygon.Stroke = Brushes.Yellow; buttonPolygon.StrokeThickness = 2; // create ControlTemplate based on polygon ControlTemplate template = new ControlTemplate(); template.Childeren.Add(buttonPolygon); // This does not work! What's the right way? //create button based on controltemplate Button button = new Button(); button.Template = template; So I need a way to set my Polygon as the button's template.. Suggestions? Thanks.

    Read the article

  • ControlTemplate for ItemsControl with remove button near each item

    - by Broken Pipe
    I'm trying to figure out hot to create ItemsControl which contains Button near each Item, clicking on it removes this item from ItemsControl. I'm new to Silverlight|WPF is it possible to create this using just ControlTemplate? I tried to create inherited ListBox with ControlTemplate that renders button near each item and then i was supposed to hook to click event get item and remove it, but I neither found a way to render button near each item, neither how to subscribe to events from ControlTemplate ;-)

    Read the article

  • How to use a derived ControlTemplate in WPF

    - by Frank Fella
    The following xaml code works: <Window x:Class="DerivedTemplateBug.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:DerivedTemplateBug" Title="Window1" Height="300" Width="300"> <Button> <Button.Template> <ControlTemplate> <Border BorderBrush="Black" BorderThickness="2"> <TextBlock>Testing!</TextBlock> </Border> </ControlTemplate> </Button.Template> </Button> </Window> Now, if you define the following data template: using System.Windows.Controls; namespace DerivedTemplateBug { public class DerivedTemplate : ControlTemplate { } } And then swap the ControlTemplate for the derived class: <Window x:Class="DerivedTemplateBug.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:DerivedTemplateBug" Title="Window1" Height="300" Width="300"> <Button> <Button.Template> <local:DerivedTemplate> <Border BorderBrush="Black" BorderThickness="2"> <TextBlock>Testing!</TextBlock> </Border> </local:DerivedTemplate> </Button.Template> </Button> </Window> You get the following error: Invalid ContentPropertyAttribute on type 'DerivedTemplateBug.DerivedTemplate', property 'Content' not found. Can anyone tell my why this is the case?

    Read the article

  • Multibinding File-Paths into a Button ControlTemplate

    - by Bill
    I am trying to develop an application that uses a number of images that are stored in a seperate remote file location. The file-paths to the UI elements are stored within the Application Settings. Although I understand how to access the images from Applications Settings using a MultiBinding and a value converter, I'm not sure how to integrate the Multibinding into the ImageButton ControlTemplate below. Can anyone steer me in the right direction? <Image.Source> <MultiBinding Converter="{StaticResource MyConverter}"> <Binding Source="{StaticResource Properties.Settings}" Path="Default.pathToInterfaceImages" /> <Binding Source="ScreenSaver.png"></Binding> </MultiBinding> </Image.Source> <Button Click="btn_ScreenSaver_Click" Style="{DynamicResource ThreeImageButton}" local:ThreeImageButton.Image="C:\Skins\ScreenSaver_UP.png" local:ThreeImageButton.MouseOverImage="C:\Skins\ScreenSaver_OVER.png" local:ThreeImageButton.PressedImage="C:\Skins\ScreenSaver_DOWN.png"/> <Style x:Key="ThreeImageButton" TargetType="{x:Type Button}"> <Setter Property="FontSize" Value="10"/> <Setter Property="Height" Value="34"/> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type Button}"> <StackPanel Orientation="Horizontal" > <Image Name="PART_Image" Source= "{Binding Path=(local:ThreeImageButton.Image), RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Button}}}" /> </StackPanel> <ControlTemplate.Triggers> <Trigger Property="IsMouseOver" Value="True"> <Setter Property="Source" Value="{Binding Path=(local:ThreeImageButton.MouseOverImage), RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Button}}}" TargetName="PART_Image"/> </Trigger> <Trigger Property="IsPressed" Value="True"> <Setter Property="Source" Value="{Binding Path=(local:ThreeImageButton.PressedImage), RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Button}}}" TargetName="PART_Image"/> </Trigger> <Trigger Property="IsEnabled" Value="False"> <Setter Property="Source" Value="{Binding Path=(local:ThreeImageButton.Image), RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Button}}}" TargetName="PART_Image"/> </Trigger> </ControlTemplate.Triggers> </ControlTemplate> </Setter.Value> </Setter> </Style> public class ThreeImageButton : DependencyObject { // Add three new Dependency Properties to the Button Class to hold the // path to each of the images that are bound to the control, displayed // during normal, mouse-over and pressed states. public static readonly DependencyProperty ImageProperty; public static readonly DependencyProperty MouseOverImageProperty; public static readonly DependencyProperty PressedImageProperty; public static ImageSource GetImage(DependencyObject obj) { return (ImageSource)obj.GetValue(ImageProperty); } public static ImageSource GetMouseOverImage(DependencyObject obj) { return (ImageSource)obj.GetValue(MouseOverImageProperty); } public static ImageSource GetPressedImage(DependencyObject obj) { return (ImageSource)obj.GetValue(PressedImageProperty); } public static void SetImage(DependencyObject obj, ImageSource value) { obj.SetValue(ImageProperty, value); } public static void SetMouseOverImage(DependencyObject obj, ImageSource value) { obj.SetValue(MouseOverImageProperty, value); } public static void SetPressedImage(DependencyObject obj, ImageSource value) { obj.SetValue(PressedImageProperty, value); } // Register each property with the control. static ThreeImageButton() { var metadata = new FrameworkPropertyMetadata((ImageSource)null); ImageProperty = DependencyProperty.RegisterAttached("Image", typeof(ImageSource), typeof(ThreeImageButton), metadata); var metadata1 = new FrameworkPropertyMetadata((ImageSource)null); MouseOverImageProperty = DependencyProperty.RegisterAttached("MouseOverImage", typeof(ImageSource), typeof(ThreeImageButton), metadata1); var metadata2 = new FrameworkPropertyMetadata((ImageSource)null); PressedImageProperty = DependencyProperty.RegisterAttached("PressedImage", typeof(ImageSource), typeof(ThreeImageButton), metadata2); } }

    Read the article

  • ContentPresenter within ControlTemplate cannot change attached dependency property

    - by happyclicker
    Why does the following simplified code not set the font-size of the TextBlock to 50? <Window.Resources> <ControlTemplate TargetType="ContentControl" x:Key="Test"> <ContentPresenter TextBlock.FontSize="50" /> </ControlTemplate> </Window.Resources> <Grid> <ContentControl Template="{StaticResource Test}"> <TextBlock>Test should be rendered big</TextBlock> </ContentControl> </Grid> If I change the value of the FontSize property, visual studio shows me the text in the size I want. After compiling or executing the app, the size of the textblock is always reset to its default size. I have also tested various versions with styles and embedded resources but I end always in the situation that I cannot set attached dp's from within a ControlTemplate that contains a ContentPresenter. Is this by design?

    Read the article

  • DataTrigger inside ControlTemplate doesn't update

    - by kennethkryger
    I have a ListBox that is bound to a list of CustomerViewModel-objects, that each has two dependency properties: - Name (string) - Description (string) - IsVisible (bool) (the IsVisible property is True by default and is reversed via the ToggleVisibility Command on the CustomerViewModel) I would like to display the Name and Description to the right of a Border-control, that is has a Transparent background when the IsVisible property is True and Green when the False. My problem is that the DataTrigger part of the code below doesn't work the way I want, because the Setter-part isn't triggered when the IsVisible is changed. What am I doing wrong? Here's my code: <UserControl.Resources> <Style x:Key="ListBoxStyle" TargetType="{x:Type ListBox}"> <Setter Property="Margin" Value="-1,-1,0,0" /> <Setter Property="BorderThickness" Value="0" /> <Setter Property="Background" Value="Transparent" /> <Setter Property="ItemContainerStyle" Value="{DynamicResource ListboxItemStyle}" /> <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Disabled" /> </Style> <Style x:Key="ListboxItemStyle" TargetType="{x:Type ListBoxItem}"> <Setter Property="Background" Value="Transparent" /> <Setter Property="FocusVisualStyle" Value="{x:Null}" /> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type ListBoxItem}"> <Grid> <Border x:Name="border" Background="{TemplateBinding Background}" BorderBrush="#FFD4D6D5" BorderThickness="0,0,0,1"> <Grid Height="70" Margin="0,0,10,0"> <Grid.RowDefinitions> <RowDefinition Height="10" /> <RowDefinition Height="Auto" /> <RowDefinition /> <RowDefinition Height="10" /> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto" /> <ColumnDefinition /> </Grid.ColumnDefinitions> <Border x:Name="visibilityColumn" Grid.Row="0" Grid.Column="0" Grid.RowSpan="4" Background="Transparent" Width="4" Margin="0,0,4,0" /> <TextBlock x:Name="customerName" Grid.Row="1" Grid.Column="1" Foreground="#FF191919" FontWeight="Bold" Text="{Binding Name}" VerticalAlignment="Top" /> <TextBlock Grid.Row="2" Grid.Column="1" VerticalAlignment="Stretch" Text="{Binding Description}" TextWrapping="Wrap" Foreground="#FFB4B4B4" TextTrimming="CharacterEllipsis" /> </Grid> <Border.ContextMenu> <ContextMenu> <MenuItem Header="Edit..." /> <MenuItem Header="Visible" IsCheckable="True" IsChecked="{Binding IsVisible}" Command="{Binding ToggleVisibility}"/> </ContextMenu> </Border.ContextMenu> </Border> </Grid> <ControlTemplate.Triggers> <Trigger Property="IsMouseOver" Value="True"> <Setter Property="Background" Value="#FFEEEEEE" /> </Trigger> <Trigger Property="IsSelected" Value="True"> <Setter Property="Background" Value="#FFF5F5F5" /> <Setter TargetName="customerName" Property="Foreground" Value="Green" /> </Trigger> <DataTrigger Binding="{Binding IsVisible}" Value="False"> <!--If Value="True" the customerName Border shows up green!--> <Setter Property="Background" Value="Green" /> </DataTrigger> </ControlTemplate.Triggers> </ControlTemplate> </Setter.Value> </Setter> </Style> </UserControl.Resources> <ListBox Style="{StaticResource ListBoxStyle}" ItemsSource="{Binding CustomerViewModels}" />

    Read the article

  • WPF: Binding to ObservableCollection in ControlTemplate is not updated

    - by Julian Lettner
    I created a ControlTemplate for my custom control MyControl. MyControl derives from System.Windows.Controls.Control and defines the following property public ObservableCollection<MyControl> Children{ get; protected set; }. To display the nested child controls I am using an ItemsControl (StackPanel) which is surrounded by a GroupBox. If there are no child controls, I want to hide the GroupBox. Everything works fine on application startup: The group box and child controls are shown if the Children property initially contained at least one element. In the other case it is hidden. The problem starts when the user adds a child control to an empty collection. The GroupBox's visibility is still collapsed. The same problem occurs when the last child control is removed from the collection. The GroupBox is still visible. Another symptom is that the HideEmptyEnumerationConverter converter does not get called. Adding/removing child controls to non empty collections works as expected. Whats wrong with the following binding? Obviously it works once but does not get updated, although the collection I am binding to is of type ObservableCollection. <!-- Converter for hiding empty enumerations --> <Common:HideEmptyEnumerationConverter x:Key="hideEmptyEnumerationConverter"/> <!--- ... ---> <ControlTemplate TargetType="{x:Type MyControl}"> <!-- ... other stuff that works ... --> <!-- Child components --> <GroupBox Header="Children" Visibility="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Children, Converter={StaticResource hideEmptyEnumerationConverter}}"> <ItemsControl ItemsSource="{TemplateBinding Children}"/> </GroupBox> </ControlTemplate> . [ValueConversion(typeof (IEnumerable), typeof (Visibility))] public class HideEmptyEnumerationConverter : IValueConverter { #region IValueConverter Members public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { int itemCount = ((IEnumerable) value).Cast<object>().Count(); return itemCount == 0 ? Visibility.Collapsed : Visibility.Visible; } public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { throw new NotImplementedException(); } #endregion } Another, more general question: How do you guys debug bindings? Found this (http://bea.stollnitz.com/blog/?p=52) but still I find it very hard to do. I am glad for any help or suggestion.

    Read the article

  • Get control in code from ControlTemplate By Name

    - by Polaris
    Hello. I have next control template in my WPF app. <Style TargetType="Label" x:Key="LabelStyle"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="Label"> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="40"/> <ColumnDefinition/> </Grid.ColumnDefinitions> <TextBox x:Name="MyTextBlock" Text="{TemplateBinding Content}" Height="20" HorizontalAlignment="Left" VerticalAlignment="Top" /> <Label Content="{TemplateBinding Content}" Grid.Column="1" Grid.Row="1"/> </Grid> </ControlTemplate> </Setter.Value> </Setter> </Style> TextBox "MyTextBlock" is invisible in C# code of window. How can I access to this textblock in code

    Read the article

  • WPF ControlTemplate vs UserControl

    - by PaN1C_Showt1Me
    Hi. I've recently made an UserControl, which took quite a long time, because I had to work with custom Dependency Properties and so on... Anyways, it was just a bunch of 3 controls: TextBox, Popup with Hierarchical Tree. Now I realized I could probably write a ControlTemplate only. Hence what is the benefit of using UserControl?

    Read the article

  • Accessing other controls by name in a Silverlight ControlTemplate

    - by Chris S
    I have a custom control that inherits from ContentControl. Inside the generic.xaml file is a simple Grid with 2 rows: Row 1 - A toggle button Row 2 - A StackPanel with a TextBlock, named "Stackpanel1" The ToggleButton has its own nested ControlTemplate which has VisualStates for Checked/Unchecked. Is it possible to reference "Stackpanel1" from inside the ToggleButton's control template somehow? In order to show or hide the stackpanel.

    Read the article

  • WinRT ControlTemplate ItemsPanel

    - by user1427149
    I'm new to WinRT and am trying to create a standard gridview which has a group heading with a number of tiles beneath it. That bit is easy. I'm trying to modify it so that beneath the grid of tiles I can also add a footer using the containers style: <GridView x:Name="itemGridView" AutomationProperties.AutomationId="ItemGridView" AutomationProperties.Name="Grouped Items" Margin="116,0,40,46" ItemsSource="{Binding Source={StaticResource groupedItemsViewSource}}" ItemTemplate="{StaticResource Project200x200ItemTemplate}" SelectionMode="None" IsItemClickEnabled="True" ItemClick="ItemView_ItemClick"> <GridView.ItemsPanel> <ItemsPanelTemplate> <VirtualizingStackPanel Orientation="Horizontal"/> </ItemsPanelTemplate> </GridView.ItemsPanel> <GridView.GroupStyle> <GroupStyle> <GroupStyle.HeaderTemplate> <DataTemplate> <Grid Margin="1,0,0,6"> <Button AutomationProperties.Name="Group Title" Content="{Binding Name}" Click="Header_Click" Style="{StaticResource TextButtonStyle}" FontWeight="{Binding IsSelected, ConverterParameter=FontWeight, Converter={StaticResource BooleanToFontWeightConverter}}" /> </Grid> </DataTemplate> </GroupStyle.HeaderTemplate> <GroupStyle.Panel> <ItemsPanelTemplate> <VariableSizedWrapGrid Background="Red" Orientation="Vertical" Margin="0,0,40,0" /> </ItemsPanelTemplate> </GroupStyle.Panel> <GroupStyle.ContainerStyle> <Style TargetType="GroupItem"> <Setter Property="Template"> <Setter.Value> <ControlTemplate> <StackPanel> <ContentPresenter/> <ItemsPresenter/> <TextBlock Text="*** End of group ***"/> </StackPanel> </ControlTemplate> </Setter.Value> </Setter> </Style> </GroupStyle.ContainerStyle> </GroupStyle> </GridView.GroupStyle> </GridView> This almost works but after adding the container style, the grid of tiles no longer shows... the group header and 'End of group' textblock is showing, but I've lost the tile grid. Can anyone spot what I'm doing wrong...?

    Read the article

  • WPF ComboBox ControlTemplate Background problem

    - by PaN1C_Showt1Me
    This is an example of a ComboBox's ControlTemplate. CLICK HERE I've tried to set the Background / add a trigger to change the background when the ComboBox is focused (with a tab key for example), both without success. I don't even understand why it isn't included by default ! (compared to the original generic template)

    Read the article

  • Silverlight with using of DependencyProperty and ControlTemplate

    - by Taras
    Hello everyone, I'm starting to study Silverlight 3 and Visual Studio 2008. I've been trying to create Windows sidebar gadget with button controls that look like circles (I have couple of "roundish" png images). The behavior, I want, is the following: when the mouse hovers over the image it gets larger a bit. When we click on it, then it goes down and up. When we leave the button's image it becomes normal sized again. Cause I'm going to have couple of such controls I decided to implement custom control: like a button but with image and no content text. My problem is that I'm not able to set my custom properties in my template and style. What am I doing wrong? My teamplate control with three additional properties: namespace SilverlightGadgetDocked { public class ActionButton : Button { /// <summary> /// Gets or sets the image source of the button. /// </summary> public String ImageSource { get { return (String)GetValue(ImageSourceProperty); } set { SetValue(ImageSourceProperty, value); } } /// <summary> /// Gets or sets the ratio that is applied to the button's size /// when the mouse control is over the control. /// </summary> public Double ActiveRatio { get { return (Double)GetValue(ActiveRatioProperty); } set { SetValue(ActiveRatioProperty, value); } } /// <summary> /// Gets or sets the offset - the amount of pixels the button /// is shifted when the the mouse control is over the control. /// </summary> public Double ActiveOffset { get { return (Double)GetValue(ActiveOffsetProperty); } set { SetValue(ActiveOffsetProperty, value); } } public static readonly DependencyProperty ImageSourceProperty = DependencyProperty.Register("ImageSource", typeof(String), typeof(ActionButton), new PropertyMetadata(String.Empty)); public static readonly DependencyProperty ActiveRatioProperty = DependencyProperty.Register("ActiveRatio", typeof(Double), typeof(ActionButton), new PropertyMetadata(1.0)); public static readonly DependencyProperty ActiveOffsetProperty = DependencyProperty.Register("ActiveOffset", typeof(Double), typeof(ActionButton), new PropertyMetadata(0)); public ActionButton() { this.DefaultStyleKey = typeof(ActionButton); } } } And XAML with styles: <UserControl x:Class="SilverlightGadgetDocked.Page" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:SilverlightGadgetDocked="clr-namespace:SilverlightGadgetDocked" Width="130" Height="150" SizeChanged="UserControl_SizeChanged" MouseEnter="UserControl_MouseEnter" MouseLeave="UserControl_MouseLeave"> <Canvas> <Canvas.Resources> <Style x:Name="ActionButtonStyle" TargetType="SilverlightGadgetDocked:ActionButton"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="SilverlightGadgetDocked:ActionButton"> <Grid> <Image Source="{TemplateBinding ImageSource}" Width="{TemplateBinding Width}" Height="{TemplateBinding Height}"/> </Grid> </ControlTemplate> </Setter.Value> </Setter> </Style> <Style x:Key="DockedActionButtonStyle" TargetType="SilverlightGadgetDocked:ActionButton" BasedOn="{StaticResource ActionButtonStyle}"> <Setter Property="Canvas.ZIndex" Value="2"/> <Setter Property="Canvas.Top" Value="10"/> <Setter Property="Width" Value="30"/> <Setter Property="Height" Value="30"/> <Setter Property="ActiveRatio" Value="1.15"/> <Setter Property="ActiveOffset" Value="5"/> </Style> <Style x:Key="InfoActionButtonStyle" TargetType="SilverlightGadgetDocked:ActionButton" BasedOn="{StaticResource DockedActionButtonStyle}"> <Setter Property="ImageSource" Value="images/action_button_info.png"/> </Style> <Style x:Key="ReadActionButtonStyle" TargetType="SilverlightGadgetDocked:ActionButton" BasedOn="{StaticResource DockedActionButtonStyle}"> <Setter Property="ImageSource" Value="images/action_button_read.png"/> </Style> <Style x:Key="WriteActionButtonStyle" TargetType="SilverlightGadgetDocked:ActionButton" BasedOn="{StaticResource DockedActionButtonStyle}"> <Setter Property="ImageSource" Value="images/action_button_write.png"/> </Style> </Canvas.Resources> <StackPanel> <Image Source="images/background_docked.png" Stretch="None"/> <TextBlock Foreground="White" MaxWidth="130" HorizontalAlignment="Right" VerticalAlignment="Top" Padding="0,0,5,0" Text="Name" FontSize="13"/> </StackPanel> <SilverlightGadgetDocked:ActionButton Canvas.Left="15" Style="{StaticResource InfoActionButtonStyle}" MouseLeftButtonDown="imgActionInfo_MouseLeftButtonDown"/> <SilverlightGadgetDocked:ActionButton Canvas.Left="45" Style="{StaticResource ReadActionButtonStyle}" MouseLeftButtonDown="imgActionRead_MouseLeftButtonDown"/> <SilverlightGadgetDocked:ActionButton Canvas.Left="75" Style="{StaticResource WriteAtionButtonStyle}" MouseLeftButtonDown="imgActionWrite_MouseLeftButtonDown"/> </Canvas> </UserControl> And Visual Studio reports that "Invalid attribute value ActiveRatio for property Property" in line 27 <Setter Property="ActiveRatio" Value="1.15"/> VERY BIG THANKS!!!

    Read the article

  • Style vs. ControlTemplate

    - by plotnick
    is it possible to define resources in the style rather then using a template? <ListView.Resources > <Style TargetType="{x:Type ScrollBar}"> <Setter Property="Background" Value="Transparent" /> </Style> </ListView.Resources> How can I wrap this thing into: <Style TargetType="{x:Type ListView}"> </Style> ?

    Read the article

  • How to start a ColorAnimation from a MultiTrigger in a ControlTemplate ?

    - by banzai
    Hi all I have the following ControlTemplate for a WPF TabItem: <ControlTemplate x:Key="DefaultTabItemTemplate" TargetType="{x:Type TabItem}"> <ControlTemplate.Resources> <SolidColorBrush x:Key="UnselectedForegroundBrush" Color="#414141" /> <!-- Unique color for this template --> <SolidColorBrush x:Key="SelectedForegroundBrush" Color="#457581" /> <!-- Unique color for this template --> <SolidColorBrush x:Key="MouseOverTextBrush" x:Name="local_MouseOverTextBrush" Color="#FFF2F2F2"/> </ControlTemplate.Resources> <Grid> <Border Name="Border" MinHeight="30" Margin="0,0,0,-1" Background="{DynamicResource TabControlBackgroundBrush}" BorderBrush="{DynamicResource ndt_DisabledForegroundBrush}" BorderThickness="1,1,1,1" CornerRadius="0,0,0,0" > <ContentPresenter x:Name="ContentSite" VerticalAlignment="Center" HorizontalAlignment="Center" TextElement.FontStretch="UltraExpanded" TextElement.FontWeight="UltraBlack" ContentSource="Header" Margin="12,2,12,2" RecognizesAccessKey="True" /> </Border> </Grid> <ControlTemplate.Triggers> <Trigger Property="IsSelected" Value="True"> <Setter Property="Panel.ZIndex" Value="2" /> <Setter TargetName="Border" Property="Background" Value="{DynamicResource ndt_TabControlBackgroundBrush}" /> <Setter TargetName="Border" Property="BorderThickness" Value="1,1,1,0" /> <Setter TargetName="ContentSite" Property="TextElement.Foreground" Value="{StaticResource SelectedForegroundBrush}" /> </Trigger> <Trigger Property="IsEnabled" Value="False"> <Setter TargetName="Border" Property="Background" Value="{DynamicResource ndt_DisabledBackgroundBrush}" /> <Setter TargetName="ContentSite" Property="TextElement.Foreground" Value="{DynamicResource ndt_DarkGray}" /> <Setter Property="Foreground" Value="{DynamicResource ndt_DisabledForegroundBrush}" /> </Trigger> <MultiTrigger> <MultiTrigger.Conditions> <Condition Property="IsMouseOver" Value="True" /> <Condition Property="IsSelected" Value="False" /> </MultiTrigger.Conditions> <Setter TargetName="Border" Property="Background" Value="{DynamicResource ndt_NavigationAreaBrush}" /> <Setter TargetName="ContentSite" Property="TextElement.Foreground" Value="{DynamicResource MouseOverTextBrush}" /> </MultiTrigger> </ControlTemplate.Triggers> </ControlTemplate> Everything works fine so far. The MultiTrigger at the end of the template defines a mouse over effect for not selected TabItems. Now I thought the change in color for this mouse over effect looks a bit brash so let´s animate it with a ColorAnimation. But don´t count the chickens before they hatch - everything I tried didn´t work. Maybe I oversee the obvious - but how to achieve this feat ? Thanks in advance banzai

    Read the article

  • MouseOver Trigger firing on ContextMenu with overridden ControlTemplate. Where is it coming from?

    - by Dabblernl
    I have this very simple ControlTemplate: <ControlTemplate TargetType="{x:Type ContextMenu}"> <Border Name="Border" Background="{StaticResource BlueBackground}" BorderBrush="LightBlue" CornerRadius="10" BorderThickness="1" > <StackPanel IsItemsHost="True"/> </Border> </ControlTemplate> I made it to create a nifty jawdroppingly beautiful rounded corner! However, when I point the mouse over a contextmenu a MouseOver Trigger fires from somewhere that draws a terribly ugly nearly square border on top of my nifty rounded border! Where is it coming from?? EDIT: The most likely cause is that the ContextMenu is an ItemsControl that holds MenuItems, even when my ContextMenu holds a single UserControl. So the UserControl is seen as a MenuItem and highlighted when the IsMouseOver==true! What is the easiest way to disable this behaviour?

    Read the article

  • TreeViewItem - Use ControlTemplate and HierarchicalDataTemplate together

    - by CrownJ
    I'm using HierarchicalDataTemplate in my TreeView, and I wanted to also overwrite the default template for the TreeViewItem so that when an item is selected, it only highlights the text, not including the icon next to it. <TreeView.ItemTemplate> <HierarchicalDataTemplate ItemsSource="{Binding Children}"> <TreeViewItem Style="{StaticResource TreeViewItemStyle}" Header="{Binding DisplayText}" /> </HierarchicalDataTemplate> </TreeView.ItemTemplate> <TreeView.Resources> <Style x:Key="TreeViewItemFocusVisual"> <Setter Property="Control.Template"> <Setter.Value> <ControlTemplate> <Rectangle/> </ControlTemplate> </Setter.Value> </Setter> </Style> <Style x:Key="ExpandCollapseToggleStyle" TargetType="{x:Type ToggleButton}"> <Setter Property="Focusable" Value="False"/> <Setter Property="Width" Value="19"/> <Setter Property="Height" Value="13"/> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type ToggleButton}"> <Border Width="19" Height="13" Background="Transparent"> <Border Width="9" Height="9" SnapsToDevicePixels="true" BorderBrush="#FF7898B5" BorderThickness="1" CornerRadius="1"> <Border.Background> <LinearGradientBrush EndPoint="1,1" StartPoint="0,0"> <GradientStop Color="White" Offset=".2"/> <GradientStop Color="#FFC0B7A6" Offset="1"/> </LinearGradientBrush> </Border.Background> <Path x:Name="ExpandPath" Fill="Black" Margin="1,1,1,1" Data="M 0 2 L 0 3 L 2 3 L 2 5 L 3 5 L 3 3 L 5 3 L 5 2 L 3 2 L 3 0 L 2 0 L 2 2 Z"/> </Border> </Border> <ControlTemplate.Triggers> <Trigger Property="IsChecked" Value="True"> <Setter Property="Data" TargetName="ExpandPath" Value="M 0 2 L 0 3 L 5 3 L 5 2 Z"/> </Trigger> </ControlTemplate.Triggers> </ControlTemplate> </Setter.Value> </Setter> </Style> <Style x:Key="{x:Type TreeViewItem}" TargetType="{x:Type TreeViewItem}"> <Setter Property="Background" Value="Transparent"/> <Setter Property="HorizontalContentAlignment" Value="{Binding HorizontalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/> <Setter Property="VerticalContentAlignment" Value="{Binding VerticalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/> <Setter Property="Padding" Value="1,0,0,0"/> <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/> <Setter Property="FocusVisualStyle" Value="{StaticResource TreeViewItemFocusVisual}"/> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type TreeViewItem}"> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto"/> <ColumnDefinition Width="Auto"/> <ColumnDefinition Width="*"/> </Grid.ColumnDefinitions> <Grid.RowDefinitions> <RowDefinition Height="Auto"/> <RowDefinition/> </Grid.RowDefinitions> <ToggleButton x:Name="Expander" Style="{StaticResource ExpandCollapseToggleStyle}" ClickMode="Press" IsChecked="{Binding IsExpanded, RelativeSource={RelativeSource TemplatedParent}}"/> <StackPanel Orientation="Horizontal" Grid.Column="1" > <Image Width="16" Height="16" Margin="3,0" Source="{Binding Path=ImageSource}" /> <Border x:Name="Bd" SnapsToDevicePixels="true" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Margin="0" Padding="0"> <ContentPresenter x:Name="PART_Header" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" ContentSource="Header"/> </Border> </StackPanel> <ItemsPresenter x:Name="ItemsHost" Grid.Column="1" Grid.ColumnSpan="2" Grid.Row="1"/> </Grid> <ControlTemplate.Triggers> <Trigger Property="IsExpanded" Value="false"> <Setter Property="Visibility" TargetName="ItemsHost" Value="Collapsed"/> </Trigger> <Trigger Property="HasItems" Value="false"> <Setter Property="Visibility" TargetName="Expander" Value="Hidden"/> </Trigger> <Trigger Property="IsSelected" Value="true"> <Setter Property="Background" TargetName="Bd" Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}"/> <Setter Property="Control.Foreground" TargetName="Bd" Value="{DynamicResource {x:Static SystemColors.HighlightTextBrushKey}}"/> </Trigger> <MultiTrigger> <MultiTrigger.Conditions> <Condition Property="IsSelected" Value="true"/> <Condition Property="IsSelectionActive" Value="false"/> </MultiTrigger.Conditions> <Setter Property="Background" TargetName="Bd" Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"/> <Setter Property="Control.Foreground" TargetName="Bd" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/> </MultiTrigger> <Trigger Property="IsEnabled" Value="false"> <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/> </Trigger> </ControlTemplate.Triggers> </ControlTemplate> </Setter.Value> </Setter> <Style.Triggers> <Trigger Property="VirtualizingStackPanel.IsVirtualizing" Value="true"> <Setter Property="ItemsPanel"> <Setter.Value> <ItemsPanelTemplate> <VirtualizingStackPanel/> </ItemsPanelTemplate> </Setter.Value> </Setter> </Trigger> </Style.Triggers> </Style> </TreeView.Resources> I couldn't find a way to use both the HierarchicalDataTemplate and ControlTemplate together so I can specify the ItemsSource and also change parts of the control's behavior. When I do the above code, it won't select the treeviewitem at all.

    Read the article

  • Image Source In ControlTemplate WPF

    - by Asim Sajjad
    I have a ControlTemplate which is for the Button control, in the ControlTemplate I have Image control which is used to displayed in the button, Now I want to set the Image Source at runt time as I have to copy paste the ControlTemplate for each of the button to set new image for new button. Thanks in advance.

    Read the article

  • Silverlight 3 - HeaderedItemsControl ControlTemplate

    - by user208662
    Hello, I am trying to create a HeaderedItemsControl where the headers are frozen. In an attempt to accomplish this, I have been trying to build on the default control template generated by Blend. I am using this default template in the following manner: <controls:HeaderedItemsControl x:Name="informationItemsControl"> <controls:HeaderedItemsControl.Template> <ControlTemplate> <Grid x:Name="Root"> <Grid.RowDefinitions> <RowDefinition Height="Auto"/> <RowDefinition Height="*"/> </Grid.RowDefinitions> <ContentControl x:Name="HeaderContent" Content="{TemplateBinding Header}" ContentTemplate="{TemplateBinding HeaderTemplate}"/> <ItemsPresenter x:Name="Items" Grid.Row="1"/> </Grid> </ControlTemplate> </controls:HeaderedItemsControl.Template> ... </controls:HeaderedItemsControl> Oddly, when I use the default template, a blank screen appears in my application. A JavaScript error bubbles up that says: Error: Unhandled Error in Silverlight Application Code: 2012 Category: ParserError Message: Unknown attribute Content on element ContentControl. File: Line: 6 Position: 107 Source File: http://localhost:2995/ Line: 60 I noticed that this error appears as long as either Content="{TemplateBinding Header}" or ContentTemplate="{TemplateBinding HeaderTemplate}" exist in the ControlTemplate. If I remove both of those, the items appear just fine (but no header). I tried with a simple header that was just a TextBlock and I still received the error. What am I doing wrong? How do I get the Header to display within the ControlTemplate?

    Read the article

  • Scale transform in xaml (in a controltemplate) on a button to perform a "zoom"

    - by Matt B
    Hi all, I've got a button with an image in it and it's being styled by the following: <ControlTemplate x:Key="IconButton" TargetType="Button"> <Border> <ContentPresenter Height="80" Width="80" /> </Border> <ControlTemplate.Triggers> <EventTrigger RoutedEvent="Button.Click"> <BeginStoryboard> <Storyboard TargetProperty="Opacity"> <DoubleAnimation From="1" To="0.5" Duration="0:0:0.5" /> <DoubleAnimation From="0.5" To="1" Duration="0:0:0.5" /> </Storyboard> </BeginStoryboard> </EventTrigger> <EventTrigger RoutedEvent="Mouse.MouseEnter"> <BeginStoryboard> <Storyboard TargetProperty="Width"> <DoubleAnimation From="80" To="95" Duration="0:0:0.2" /> </Storyboard> </BeginStoryboard> </EventTrigger> <Trigger Property="IsMouseOver" Value="True"> <Setter Property="Cursor" Value="Hand"/> </Trigger> </ControlTemplate.Triggers> </ControlTemplate> Button is as follows: <Button Template="{StaticResource IconButton}" Name="btnExit"> <Image Source="Images/Exit.png" /> </Button> The problem is that the width doesn't change when my mouse goes over. (Or at least - the width of the image does not...) I believe there is a "scale" transform I can use to enlarge the button and all it's contents? how would I do that here...? Thanks.

    Read the article

1 2 3 4 5 6 7 8 9 10  | Next Page >