controltemplate

VirtualizingStackPanel stops working when overriding the default control template for ScrollViewer

老子叫甜甜 提交于 2019-12-02 02:39:10
I have a listbox with a lot of items which are expensive to render. However the VirtualizingStackPanel takes care of that by only rendering the visible items. I want to override the control template for ScrollViewer since the default one has grey rectangle between the horizontal and vertical scrollbar. I just copied the one provided by Microsoft ( ScrollViewer ControlTemplate Example ) which do not have the grey rectangle issue. This controltemplate however disables virtualization by giving the VirtualizingStackPanel endless height. That means that the VirtualizingStackPanel will render all

WPF: IsPressed trigger of ControlTemplate not working

老子叫甜甜 提交于 2019-12-02 00:26:15
I use a custom control named ImageButton to display a button with different images. ImageButton contains dependency properties: public ImageSource DisabledImageSource { get { return (ImageSource)GetValue(DisabledImageSourceProperty); } set { SetValue(DisabledImageSourceProperty, value); } } public ImageSource NormalImageSource { get { return (ImageSource)GetValue(NormalImageSourceProperty); } set { SetValue(NormalImageSourceProperty, value); } } public ImageSource HoverImageSource { get { return (ImageSource)GetValue(HoverImageSourceProperty); } set { SetValue(HoverImageSourceProperty, value);

Change disabled listbox background to gray

孤街醉人 提交于 2019-12-01 20:09:54
I have a ListBox which I need to gray out when it's disabled. Per user request it's not enough to disable it, but it also has to appear differently. shrugs I've looked in several other places and followed the examples, and it seems as if it should work, but it does not. Here are some examples I looked at: Example1 , Example2 . Here is my code: <Style x:Key="ListBoxStyle" TargetType="ListBox"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type ListBox}"> <ControlTemplate.Triggers> <Trigger Property="IsEnabled" Value="False"> <Setter Property="BorderBrush" Value=

How to create a WPF combobox flat style?

放肆的年华 提交于 2019-12-01 17:32:50
I want to create a flat style template for WPF combobox which looks like a combobox in Visual Studio 2010. Also I want to use Visual Studio brushes for this template. Does anybody help me to find the way? Are there any completed templates? Also does anybody know something about an application that can get controls templates from other applications? Do you mean toolbar combobox toolbar style? Try this <ComboBox Style="{StaticResource {x:Static ToolBar.ComboBoxStyleKey}}"/> Here's a link to the standard combobox styles and templates: http://msdn.microsoft.com/en-us/library/ms752094.aspx . You

How to create a WPF combobox flat style?

喜夏-厌秋 提交于 2019-12-01 16:52:19
问题 I want to create a flat style template for WPF combobox which looks like a combobox in Visual Studio 2010. Also I want to use Visual Studio brushes for this template. Does anybody help me to find the way? Are there any completed templates? Also does anybody know something about an application that can get controls templates from other applications? 回答1: Do you mean toolbar combobox toolbar style? Try this <ComboBox Style="{StaticResource {x:Static ToolBar.ComboBoxStyleKey}}"/> 回答2: Here's a

RectangleGeometry with relative dimensions… how?

谁说胖子不能爱 提交于 2019-12-01 16:17:11
I'm trying to replicate the nowadays so fashionable "reflex" effect on a controltemplate for buttons I'm creating. The basic idea is to create a rectangle with a gradient fill from white to transparent and then clip some of that semi-transparent rectangle with a rectanglegeometry. The problem is that I don't know how to define a relative rectangle geometry. I kind of worked around width by defining a large value (1000), but height is a problem. For example, it works good for buttons that have a 200 height, but doesn't do anything for smaller buttons. Any ideas? <Rectangle RadiusX="5" RadiusY=

ComboBox ControlTemplate Drop Down Button

时光总嘲笑我的痴心妄想 提交于 2019-12-01 09:13:57
问题 I was wondering if anyone had an example of how to style/template a combobox to only show a button at its default initial state. Kind of like the DropDownButton gallery for the ribbon bar. I would just like the user to be able to click a button and have the combobox items listed. When the selection is made it does not save the selected item in the text field because there is no text field only a button. Thanks :) 回答1: Here's some sample code: Note that the ContentPresenter and PART

When overriding WPF templates do I have to override each theme's template separately?

牧云@^-^@ 提交于 2019-12-01 06:40:35
I have a requirement to change a very small part of the WPF ComboBox's template. If I take a copy of the existing template for the Luna theme and make the change it all works fine initially. But if the user has a different theme, my ComboBox retains it's custom theme, (Which is obviously based on Luna) so looks out of place. Is there any way of overriding just parts of a template so the majority of the template still respects the windows theme? I notice that parts of the template define an mwt namespace with an explicit reference to Luna: xmlns:mwt="...blah blah...=PresentationFramework.Luna"

How to access the elements of a ControlTemplate in Xamarin Forms

徘徊边缘 提交于 2019-12-01 04:40:18
I have a ControlTemplate defined in App.xaml. Now, I need to be able to handle certain UI events. In Visual Studio's XAML editor, if I attach a handler to an event, the handler is created in App.xaml.cs. However, I need to do this in pages that use this control template. I'm thinking the only way is to iterate through the elements in the control template and find the right element and create handlers in pages. However, I'm not sure how to access the elements from the ControlTemplate object. Does Xamarin provide a way to peek into the contents of a ControlTemplate? If you have Page instance you

WPF: Why shouldn't I use {TemplateBinding Margin} in ControlTemplate - is Margin meant only for element's containers?

和自甴很熟 提交于 2019-12-01 03:41:28
I have created my own ControlTemplate for Button, like this: <Style x:Key="LightButtonStyle" TargetType="{x:Type ButtonBase}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type ButtonBase}"> <Border x:Name="WrappingBorder" Margin="{TemplateBinding Margin}" ... > <ContentPresenter Content="{TemplateBinding Content}" ... > </ContentPresenter> </Border> </ControlTemplate> </Setter.Value> </Setter> </Style> Now, I have noticed that when I set margin to my button, like: <Button Style="{StaticResource LightButtonStyle}" Margin="20" > Hello world! </Button> the button