I want to define a grid style in the app.xaml, including the background color.
However, setting the color there, makes the whole content instantly invisible.
When application is executed, the following appears:
For a short moment, the button is visible.
How do I prevent this from happening, keeping in mind, that I wish a global background color for grids.
You can use a global style for the Grid as you have done it.
The issue you have faced comes from Visual Studio. So the issue is only present, if you start the application via Visual Studio.
To give the possibility for live tracking of UI-Elements the VS seems to add an AdornerLayerWindow, which, I suppose, also uses a Grid, which you see. You can find this window in Application.Current.Windows.
To get rid of this behaviour you have to deactivate option Options->Debugging->UI-Tools for XAML activate
Related
I want a button that
Displays an image with NO border, NO background, NO text
If I tab into the imagebutton, THEN it shows the background and border
Also if I hover over it, it shows the background and border
I've searched and I've tried so many different things, but nothing it exactly what I want. I've tried setting various properties on the button to make the background and border transparent, but it still shows up. I've tried a style with a custom control template. I'd rather not have to completely reinvent all the triggers etc to get the button to render on mouse over. The biggest problem with custom control template is that then I loose all existing functionality and I'm basically building a new control from the ground up.
Here is another link that came closest to what I wanted but it doesn't properly work for me.
How do you completely remove the button border in wpf? - BUT.... for some reason the hover effect gets stuck. One I mouse over the image and the button border draws, it stays stuck on until I click somewhere else.
Actually, you will want to override the control template. You're not "losing" any functionality (aside from the UI triggers).
Original/Default Template -- This is a good starting point... copy/paste that into you're XAML (wherever you want to style this button... ie Button resources, UserControl/Window resources, App Resources?). From there make your adjustments.
Another easy way is to use Expression Blend. You can easily create a new template based on the existing template, and the styling/authoring tools it provides are much better than hand-coding XAML (unless you're good at doing that).
As far as displaying an image instead of text, just set the image as the content. A Button is a type of ContentControl which means that it can house any type of content (Object).
I'm working on an app where I want the color of a few borders to change depending on the users choice of theme. The borders are partly placed in the xaml, but also dynamically generated throughout the app depending on choices the user make. I am also using a few LoopingSelector controls (from the Silverlight toolkit), that in turn also generate borders.
So, I was wondering how I should approach this problem. Initially I tried applying a style to the borders, and then changing the style depending on the choice of theme, but apparently styles are read-only during run time. I also figured I could iterate through and change the color of the borders, but it seems the LoopingSelector doesn't expose that property of its borders, or really, expose the controls at all.
So I assume I should use binding in some way, but as I'm still quite new to Silverlight I'm not really sure how to go about that.
Thanks in advance.
If you have a named resource, say CustomBorderBrush, that you are using in your XAML for the parts that are in the XAML, then you can access this brush from the Application's resources:
Border newBorder = new Border();
newBorder.BorderBrush = (Brush)Application.Current.Resources["CustomBorderBrush"];
If you additionally have a problem with the LoopingSelector, then that's a separate issue :) It sounds like you need to apply your own style to the LoopingSelector so that you can specify the brush value that you need.
Silverlight Intelliscence in VS 2010 does not recognize new controls on page.
Solution needs built for the intelliscense to recognized the newly placed control (textbox label extra)
Is this a BUG?
Edit: controls are not custom, they are siple label and textbox and button controls.
Edit:
button from toolbox dragged to designer,
switched to home.xml.cs
types button1
error, intelliscence doesnot recognize the button1 added.
must build each time.
what is the solution to this problem
Its not bug, its feature. Custom controls must be compiled before you can use it.
The intellsense shows what is available to source code at the time of editing. Source code has no real access to the Xaml. What you see from the Xaml in intellisense is actually in YourUserControl.g.i.cs file, which is an auto generated from the Xaml. You can see this file by selecting "Go To Definition" from the context menu of the InitialiseComponent method.
There is often a delay between the edit of the Xaml and the re-generation of this file, at times it never updates. However saving the Xaml always regenerates the file. I've become accustomed to always save the Xaml file before editing code-behind to ensure the intelisense is up to date.
Is there a way to globally change the validation template? I need to make a couple of minor tweaks to it and I don't want to have to edit every single template.
To my knowledge, no there isn't. If you're talking about the red border and the sliding popup around TextBoxes, ComboBoxes, etc. They are coded into each control's own ControlTemplate and not referenced (like a Behavior) from a common source. You'd have to redefine the implicit styles for all used basic control, or write your own validation behavior which is independent of the control (e.g. put a red border around it and write some text too) and attach it to every control you use.
I have a WPF app with a few Tabs. I'm now messing around with styling and have for example changed the ControlTemplate so I now have to define everything about the TabItem.
Now the TabItem that is selected seems detached from the document below because of some thin line around that content (there is no border). I'm not sure what technique to use to make it look attached again.
My guess would be that the Header-template is responsible for the problem. You can style that too tho - see this example for details: http://www.switchonthecode.com/tutorials/the-wpf-tab-control-inside-and-out