.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Single control template for buttons

Posted By:      Posted Date: October 25, 2010    Points: 0   Category :WPF

I have created all my buttons such that they are made up of a rectangle and a path figure. The aim is so I should be able to apply a same control template triggers to all of them - for IsPressed, IsMouseOver and the standard look.

I want to be able to pick the actual template ('path' figure for each button) from an external source and not embed it within the template definition. Otherwise, I am having to define same trigger behaviors for each button separately.

Any suggestions?


In the example code below, I want to put several 'Path' or the entire 'Grid' outside of the style.

<Style x:Key="MyButton" TargetType="{x:Type Button}" BasedOn="{x:Null}"

View Complete Post

More Related Resource Links

single form multiple buttons in MVC


In a single page  has two buttons , ddown and tempname.

I wrote two actionresult separetly each one for ddown and tempname.

I need one is post and another one is get method. so i gave like

1. Get Method


        [AcceptParameter(Name = "button", Value = "tempname")]
        public ActionResult ddown_tempname(string statusName, NewsLetterAdminViewModel viewModel)

return View();



2.Post Method


        [AcceptParameter(Name = "button", Value = "ddown")]
        public ActionResult ddown(string statusName, string button, NewsLetterAdminViewModel viewModel, FormCollection collection)

return View();



if i call the post method its worked well. but if i call the get method, the code does not execute. the brea

Where is the Visual Studio 2008 Web Control Library Template


Does a project exist for grouping user controls? Visual Studio 2005 had this template but it does not appear to exist in 2008.

We will be creating several User Controls and would like them grouped accordingly.


Thanks in advance for any responses.

Can't get ClientID of ASP control in Rendering template

Hi, I've made custom field with its own rendering template. Inside template i need to show/hide some controls, but i cant get ClientID of them. Inside rendering template : <%@ Assembly Name="XXX, Version=, Culture=neutral, PublicKeyToken=72277ea422a3515d" %> <%@ Assembly Name="Microsoft.Web.CommandUI, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> <%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> <%@ Register Tagprefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> <%@ Register Tagprefix="asp" Namespace="System.Web.UI" Assembly="System.Web.Extensions, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35" %> <%@ Import Namespace="Microsoft.SharePoint" %> <%@ Register Tagprefix="WebPartPages" Namespace="Microsoft.SharePoint.WebPartPages" Assembly="Microsoft.SharePoint, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> <%@ Control Language="C#" AutoEventWireup="true&q

Creating a volume control slider/setting one template property based on another

So, what I want to do, is to make a volume control that looks like a right angle triangle with the 90 degree angle on the bottom right, and then when you click on it, the area to the left of the selected point is shown in a different color.  In other words, I've created a slider with the right background, what I can't do, is work out how to show the selected area by filling in the triangle.  I have worked out how to bind the height of my triangle on the left to the value of the control, but right now, the rate of rise is exactly half of what I need it to be.  I need to know how to change the template for the area to the left of the selection ( which is the repeat button ) so that the background is twice the height that it is right now.  No matter what size I make the slider, the area is always 1/2 the size it needs to be, so I am sure if I could get it to double inside my template, it would work fine. <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">       <Style x:Key="SliderButtonStyle" TargetType="{x:Type RepeatButton}">         <Setter Property="SnapsToDevicePixels" Value="true"/>         <

Get visual clues back when using a control template

This something I dropped for a while.  I am attempting to use a control template to get a left and right (sort of jukebox) look.  When I do this all visual clues such as selection are lost.  The XAML for the listbox and the control templates are as follows: <Window x:Class="Window3" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Window3" Height="300" Width="513" > <Window.Resources> <Style x:Key="NoButtonBorder" TargetType="{x:Type Button}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type Button}"> <ContentPresenter Margin="{TemplateBinding Padding}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" ContentTemplate="{TemplateBinding ContentTemplate}" RecognizesAccessKey="True" Content="{TemplateBinding Con

Adding a custom control to the SharePoint 2010 Team Site Wiki Page Template ( wkpstd.aspx ) programm

Topic This is maybe my last post about the Team Site Wiki Page customization with the aim of exceeding its limitations. This time we are going to customize the unique template ( wkpstd.aspx) by replacing the control that renders the editable content by a custom one. In this post example, we will take advantage of the use of this custom control to render not editable additional contents, for instance, a header and a footer that could be the same for a specific Wiki Page Library. Of course, we are not going to really customize the template, but we are going to use a delegate control to replace the control at runtime. Here are the screen shots of the result: We can see a non editable Header and Footer on the Team Site Wiki Page In edit mode these additional contents are not rendered, but we can add new content as usual And of course, after having saved the page, the new content is rendered wtih the non editable Header and Footer. Steps required   If you look at the Team Site Wiki Page template, wkpstd.aspx, you can see the control that is rendering the editable content/ <SharePoint:EmbeddedFormField ID="WikiField" FieldName="WikiField" ControlMode="Display" runat="server" /> We are first going to create a custom EmbeddedFormField control Then, we are going to use a delegate control to replace the native EmbeddedFor

how to find control from header template of a datalist?

 Hi,I have a textbox in header template of a datalist. From code behind i've to access these textbox from page_load event.I tried with the following code. DataList.Controls[0].FindControl("myControl") But it have error. how to solve it? 

Insert and Edit Pages with Web User Control Template for another table

Hi, I have an Address template(web user control) which holds the fields of the Address table.  The Address template is embedded in the School Insert Page.  I want to insert a new school together with its address(which means I have to insert a record into the address table).  Can you let me know how I can pass the newly generated addressId to update school table?  Also, how can I associate the Address.cs in the App_Code with the Address template?  I want it to be able to scaffold columns which needs to be hidden from user in the address table.  When I click on Insert School, the Address template shows in "insert" mode, I just need to link the two together. Thanks for your help! CC  

Can't access a control in a listview layout template with codebehind

While running ItemDetabound upon load of a listivew, I am trying to access the text in a label of the LayoutTemplate of a different Listview.  It works fine if I try access the same labels under the same names if they are in the same listview, but not if they are in a different one.  It was working for a while, can't figure out what I changed, but now says that object doesn't exist.   Here is the html code for the labels: <LayoutTemplate> <table ID="Table2" runat="server" cellpadding="0" cellspacing="0"> <tr ID="Tr1" runat="server" style="padding-left: 0px"> <th ID="Th1" runat="server" style="text-align: left; white-space:nowrap; "> <asp:Label ID="Label1" runat="server">Label 1</asp:Label> </th> <th ID="Th2" runat="server" style="white-space:nowrap; width: 150px" >

FontSize does not get altered when set in a control template for a button.

Hi,  I am new to WPF.  I wanted to customize the look and feel of a button , so defined this custom style/control template :        <Style x:Key="TaskbarButton" TargetType="{x:Type Button}">         <Setter Property="OverridesDefaultStyle" Value="True"/>         <Setter Property="SnapsToDevicePixels" Value="true"/>         <Setter Property="HorizontalContentAlignment" Value="Center"/>         <Setter Property="VerticalContentAlignment" Value="Center"/>         <!--<Setter Property="Width" Value="105"/>         <Setter Property="Height" Value="35"/>-->         <Setter Property="Width" Value="118"/>         <Setter Property="Height" Value="40"/>         <Setter Property="FontFamily" Value="Tahoma"/>         <Setter Property="FontSize" Value="13"/>         <Setter Property="FontWei

Cannot populate XAML items in template control that in contained within another template control

I have a template control Bookmark, and in MainWindow.xaml, this works just fine: <sdl:Bookmark> <sdl:Bookmark.Bookmarks> <sdl:BookmarkItem Name="test" Extent="-121.89,33.60,-117.09,36.32"> </sdl:BookmarkItem> </sdl:Bookmark.Bookmarks> </sdl:Bookmark> But, I also have a template control Titlebar which inside of its XAML contains a Bookmark control and in MainWindow.xaml, this does NOT work: <sdl:Titlebar x:Name="Titlebar"> <sdl:Titlebar.Bookmark> <sdl:Bookmark.Bookmarks> <!-- Doesn't like this --> <sdl:BookmarkItem Name="test" Extent="-121.89,33.60,-117.09,36.32"> </sdl:BookmarkItem> </sdl:Bookmark.Bookmarks> </sdl:Titlebar.Bookmark> </sdl:Titlebar> I get this error: Error 11 The tag 'Bookmark.Bookmarks' does not exist in XML namespace 'clr-namespace:SDL.ArcGIS.Client.Toolkit;assembly=SDL.ArcGIS.Client.Toolkit'. Line 45 Position 22. C:\Projects\SDL.ArcGIS.Client.Toolkit\SDL.ArcGIS.Client.Toolkit.WPFTestApplication\MainWindow.xaml 45 22 SDL.ArcGIS.Client.Toolkit.WPFTestApplication Bookmark does have a member property in the Titlebar class that is set to the template bookmark in OnApplyTemplate.  I tried making a dependency property for the Bookmark property too, but that didn't

How to make cause validation false for Show Edit buttons in Gridview control

  HI. I am having 2 (dept name, City)dropdownlist, 1 Save button once if we click the save then record will be displayed in grid (Gridview with ShowEditbutton =true and I have Edit logic in my page). But if I click on Edit button then if I try to update the value then it is firing a message "Select dept" because dept dropdown present in the page so I want to make cause validation false for Show Edit buttons (update and cancel). Pleaase tell me Thanks

Style Trigger or or Control Template to swap GradientStops


I have an Ellipse that is part of a UserControl.

     <GradientStop Color="{Binding Path=CommandBg, FallbackValue=DarkBlue}" Offset="{Binding Path=CommandGradient,FallbackValue=2}" />
     <GradientStop Color="White" Offset="0" />

The Grid Has two events:


And on the mouse down event I want to swap the GradientStop properties, and then on MouseUp, swap them back.

How can this be accomplised in XAML?



Missing Custom Control Library Project Template in Visual C# 2010 Express?


I am using Microsoft Visual C# 2010 Express Version 10.0.30319.1 RTMRel and I want to add a Project for a WPF Custom Controls library. Note: The WPF Custom Control Item Template is included and can be added to a WPF Application project.

Does anyone know:

  1. Should the WPF Custom Control Library Template be part of this application edition?
  2. Where is the online documentation that states exactly which features are and are not included in each edition?
  3. What can be recomended as a work around?


How to save a multiple user control to a few single record text?

I have a list with people pecker control that admits multiple users.
I like to have another list with one record for each user in the control that loaded before.
Is there any way in InfoPath or in a workflow to use something like FOR EACH to take one by one user in a control and write/update records after that?
Thank in advance

Load control template file /_controltemplates/TaxonomyPicker.ascx failed

What is problem
Load control template file /_controltemplates/TaxonomyPicker.ascx failed: Could not load type 'Microsoft.SharePoint.Portal.WebControls.TaxonomyPicker' from assembly 'Microsoft.SharePoint.Portal, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c'.

WPF Custom Control template doesn't work



I've created a WPF custom control that goes in a DLL and I'm trying to use the control in another project.  Everything works fine except for the part of getting the control template to work. I should get an Orange background as defined below but the control just shows empty in the XAML editor and in runtime.

The code is as follows:


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;

namespace MyCustomControl
    public class CustomCtrl : System.Windows.Controls.Control
        public static readonly System.Windows.DependencyProperty ValueProperty;
        public string Value
            get { return (string)GetValue(CustomCtrl.ValueProperty); }
            set { SetValue(CustomCtrl.ValueProperty, value); }

        static CustomCtrl()

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend