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

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


Posted By:      Posted Date: September 12, 2010    Points: 0   Category :WPF
I have written my first WPF app and I can see where I will want to use many of the styles over again in other apps. Is it possible to store them in a separate file that can be loaded into new projects?

View Complete Post

More Related Resource Links

Conditional styles for selected Html.ActionLink


Hi, I am trying to add an item selected class to an Html.ActionLink, I am very new to MVC so its all a bit confusing.

So far i have each of my ActionLinks lookins like this

<li><%: Html.ActionLink("Home", "Index", "Home", new { @class = ViewData["current"] == "Home" ? "selected" : "" })%></li>

And in the controller i have

public ActionResult Index() {
            ViewData.Add("current", "Home");
            return View();

Can any one tell where i am going wrong because the links now fail to respond, basically it isn't checking the condition == Home and if it is then its failing because it doesn't get to the controller.

Any ideas would be appreciated


Can't change Gridview row colors or styles in the DataBound event


I was highlighting certain rows in my gridview using code like this in the DataBound event:

        if (e.Row.RowType == DataControlRowType.DataRow)
            int vendorCheck = 0;
            //TODO make this shorter
            if (DataBinder.Eval(e.Row.DataItem, "vendorId") != System.DBNull.Value)

Styles based on themselves?

Hi, I'd like to create e.g. a button style, change the template but keep the rest of the original button style (like minheight/height). How do I achieve this? Atm, I'm using this: <Style x:Key="Button" TargetType="Button" BasedOn="{StaticResource {x:Type Button}}"> <Setter Property="Template"> <Setter.Value> <...> </Setter.Value> </Setter> </Style> I get the following exception in visual studio (note: it just shows up in vs error window, it compiles and runs fine): "In den Eigenschaftsausdrücken wurde eine Schleife erkannt." (Unfortunately, I don't have the English excpetion message, as far as I understood it basically says you should not create a style based on itself) If I remove the BasedOn-thingy, my buttons get smaller than the normal ones and I'd like to have a solution for this where I don't have to set all the original controls' behaviors and which works also for other controls.   Tobi

Styles and derived styles at the app.xaml level

Hi, We have a bunch of standard styles (in XAML Resource Dictionaries) that are defined for company wide consumption and we merge them into our App.XAML in all our applications. In some applications we want to override some portions of the standard company wide styles again at the application level (we could do this at the window level but that is not preferrable and maintainable). But this doesn't work. What we notice is that if we have a style defined for Button in our company-wide style definition (merged into App.XAML), then we cannot derive from it and override it within our App.XAML - this probably is because there are multiple style definitions for Button and the last one replaces (rather than override) the previous. So, can anyone suggest a good way to handle this scenario? Again, we don't want to override styles at Window level, we want to do so preferrably at App level. Thanks

CreateWindowEx(...) P/Invoke Confusions with Window Styles and Extended Window Styles?

I am trying to create a window manually from C# using P/Invoke in order to make a tiny wrapper for some calls into Direct2D for a small application that is written in a functional idiom.  However, I am having a problem with a basic call: IntPtr hwnd = CreateWindowEx(0x16010000u, sWindowName, sClassName, 0x00050000u, cw_default, cw_default, cw_default, cw_default, (IntPtr)0, (IntPtr)0, hInstance, IntPtr.Zero); The first and fourth arguments which I state numerically here are bitmasks for the extended window style and the window style respectively.  I find (from Spy++) that the resulting window on execution has these style values instead: 0x16C10000u and 0x00050100u respectively.  Apparently a WS_CAPTION style is being added to my style bitmask at some point, and (perhaps consequently) WS_EX_WINDOWEDGE is being added to my extended styles.  I do not work with UIs much and have not used the window APIs from Win32 for a very long time, so perhaps I am making a silly mistake; perhaps there is some value in WNDCLASSEX that can somehow force WS_CAPTION to be added?  I am unsure if there is something obvious I am doing wrong either with the API or from the C# side.  Could I be making a marshalling mistake in the P/Invoke itself?  My extern declaration looks like this: [(DllImport("user32.dll")] s

applying styles to xml element while reading it from webservices

hi,i have one xml document. i used to read the xml from webservices using c# and display the xml document content in the popup window. i wish to apply style for the xml element in the xml document. codes:  xml document:       <?xml version="1.0" encoding="utf-8" ?> <BubbleHelp> <Module name="ADMIN"> <HelpItem ID="BRANCHID"> <B>Hello</B>World!! ---bold format style is not applying while display it in the popup window </HelpItem> </Module> </BubbleHelp> webservice code used to read the xml document.      helpTopic[0]  = tagnode.InnerText; //text between the node i.e Hello World!!        

Styles in Wiki Page versus Web Part Page

Hi there, I have a web part that was working perfectly fine in a wiki page (in the site pages library) - however as soon as I add that web part to a webpart page I lose some of my styles that are applied inline. More specifically I had some inline styles in a <tr> tag to show a border-bottom however that border-bottom just does not display in the webpart page. In the wiki page it displays perfectly fine. Any help is appreciated. Note: The reason I don't want to use a wiki page is because of this known problem: http://support.microsoft.com/kb/981227 Thanks  

how to apply styles on the message displayed by asp.net required field validator control?

 Hi,I want to apply styles on the message (i.e. Name field is required) display by the asp.net required field validator control.Styles=border, padding, background-color, font-color, font-weight, img etcAnd I also want highlight the border or asp.net textbox and asp.net dropdown list with which this control is associated.  RequiredFieldValidator does not have style property !Can anyone let me know how can I do this???Regards,Dazy

Styles not applied

i have a setup like <ribbon:RibbonGallery> <ribbon:RibbonGallery.Resources> <Style TargetType="ribbon:RibbonGalleryItem"> <Setter Property="Width" Value="24" /> <Setter Property="Padding" Value="0" /> </Style> <Style TargetType="Rectangle"> <Setter Property="Width" Value="16" /> <Setter Property="Height" Value="16" /> </Style> </ribbon:RibbonGallery.Resources> <ribbon:RibbonGalleryCategory Header="Automatic Color" HeaderVisibility="Collapsed" IsSharedColumnSizeScope="True"> <ribbon:RibbonGalleryItem Width="auto"> <StackPanel Orientation="Horizontal"> <Rectangle Fill="Black" /> <TextBlock Text="Automatic Color" Margin="12,0,0,0" FontWeight="Normal" /> </StackPanel> </ribbon:RibbonGalleryItem> </ribbon:RibbonGalleryCategory> <ribbon:RibbonGalleryCategory x:Name="themeColors" Header="Theme Colors" MinColumnCount="10" MaxColumnCount="10"> <ribbon:RibbonGalleryCategory.ItemTemplate> <DataTemplate> <Sta

Hover and Selected Styles for Menu

I am using the following code to create a static menu, but using images instead of text..   <asp:Menu ID="Menu1" runat="server"> <Items> <asp:menuitem navigateurl="default.aspx" text="" imageurl="Images\nav_Home.gif" popoutimageurl="Images\nav_Home_selected.gif" tooltip="Home"> </asp:menuitem> Can anyone tell me if it's possible and how to perform an image swap on hover and also an image swap on click so that it is clear which menu item has been selected? Many thanks. 

ASP.net Website - Styles and Java script not working on Mozilla firefox



       I developed a ASP.NET website. The style sheets are loading and the site is working well on Internet explorer. But When I open in Mozilla firefox/ google chorme The sytle sheets doesnt work and the javascript also doesnt work. I am not sure what to do to make my website compatible with firefox/chrome. Can someone tell me what needs to changed or where the problem usually arises in this kind of scenarios?



WPF List box styles

Im quite new to WPF , I really what to turn a listbox on its side so the content images scroll left to right .  Hence the selection being in the image in the centre.  

What i really want to achive is simular to this http://steverodgers.blogspot.com/2008/01/wpf-coverflow-clone.html  but as im quite new to wpf im not sure how these styles are asigned to the listbox and im waiting to hear back from the aurthor.

If anyone can give me an example of one of the above that would be a real help .   ideally as much code as posible to the title block so i can how it all ties in .



Styles: Setting Properties in deeper hierarchies


I'm not sure how to do a search on this, so I decided to rather ask it instead of doing hours of searching.

I have a class with DependencyProperties and use that class in a UserControl. I use that UserControl in a Window and in that Window I use the Window's Resources to set some Properties on the UserControl. I now like to set some DependencyProperties on that class, which would automatically reflect on the UserControl due the binding.

Is there a way to do it? I couldn't figure it out to do it in the .xaml, which is where I'd like to do this particular task.

css styles are not applied to the page when we use IE8 browser in normal mode


Hi All,


            I have development .net application using CSS.  which is is working fine in ie7.0. Now i am clinet want to use IE8. But some of CSS styles are not applied to the page when we use IE8 browser.  I am anable to lock the gridviw header in IE8 browser. I dont to want to apply compatibility mode as it is working fine. In normal IE8 mode I want to lock gridview header. Is it possible. Please give solution.




Ramadurai Jayaraman

How to add custom styles to RSS viewer webpart in MOSS 2007?


Hi All,

How can I customize my RSS viewer webpart in MOSS 2007. I am talking about the styles like, alternate row colors, etc..


Thanks in advance...

Default Styles for Controls


I have been using the toolkit for 3 years and update it as new releases come out but recently (after the 10/09 update) whenever I try to use the default styles with a control they don't display.  For instance, the calendar extender and the validator callout extender are missing their default styles.  Well only part of that statement is true.  With the validator callout the  ! image displays but no other style is present.

Any ideas on what to do or what could be going on?  I have cleared out my IE cache, history, cookies and still experience it. 

Custom site definition with embeded styles


I am making a custom site definition. I am able to embed master page in my site definition. This is corresponding thread for it.

Now in same way I want to embed style sheets with site definition. How I can do it ?

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