I need to have button have 4 images that are changed by the application action.
I want to define new class ButtonEx that inherit from the Button class.
So, i did it by adding 'silverlight template control' and it to be inherit from control to Button.
Now, i cant see the images whan i put this ButtonEx on the page.
What i did wrong ?
How to fix it ?
( same code work fine in WPF )
Can you post any of your code? Did you create a visual style for it in themes\generic.xaml? Did you set the default style key?
I recently followed this tutuorial for a TextBox, you could so something similar for your button... http://www.silverlightshow.net/items/Create-a-Custom-Control-Inheriting-from-TextBox.aspx
Store your images as resources then create a user control that has
- a button and the content of the button is an image
- a property to select the image from the resources
use the usercontrol as your button.
please post a code sample...
to inherit form button you simply need this.
public class ButtonEx:Button
{
}
this will have all functionality that button has.
if you want new template just add it in Themes/generic.xaml
From your question its not clear that you really need to be subclassing Button. Maybe you can get by with just copying and modifying the template of button (Blend helps for this), or just have the image as content bound to some property for the application to change (using a ValueConverter perhaps).
Related
I want to be able to allow a user to set a module as a Favorite by toggling a star icon that is placed on each tab. Is this possible using Infragistics XamTabs?
The technique you want to use is to template the tab header. You should create a style that targets the TabItemEx and provide a HeaderTemplate.
In my sample I added a Radio Button and an Image to the header which are bound to an IsFavorite property in my viewmodel causing the image to be visible when the radio button is checked. The VisConverter converter is being used to toggle the visibility property of the image.
See more details and my sample here.
http://community.infragistics.com/forums/p/67815/344088.aspx#344088
Like the title said,how may i turn the grid(or page) and the components in it into background gray and unable and show a new component in foreground.
It's a common effect in the web page,but i cannot do that with a xaml.
Please answer in detail better with sample code if you do.Thanks in advance.
Here's an example of using a Popup to display a UserControl when a Page is navigated to. The OnNavigatedTo function creates a popup, binds a Click event to the UserControl, and then shows the UserControl over the entire page. If the correct password is entered, ("password" in the example) the control disappears. You'll need to modify it for your own requirements, but it should definitely get you started.
https://skydrive.live.com/redir.aspx?cid=ef08824b672fb5d8&resid=EF08824B672FB5D8!343
You'll want to use the VisualStateManager and create some animation transitions to switch between the old and new components. I won't paste the code here for brevity, but if you check out:
http://visualstudiomagazine.com/articles/2011/07/22/wcmob_visual-states.aspx
You'll see a simple example of switching between two UI components on a single page within a Windows Phone 7 PhoneApplicationPage. In your scenario, you'd use this paradigm to create 2 animation storyboards, one for showing an overlay control and one for settings the 'disabled' property on the main grid.
I would like to create a combobox without any textbox and with a customizable icon in the button that opens the combobox. Something like this image (forget about the checkboxs)
I don't need you to post the solution, just some directions or resources so I can know how to begin this customization.
TIA
ContextMenuStrip which you manually display in the button's Click handler.
In my page I want the button that looks like the HyperlinkButton (underline when MouseOver etc). But I want to handle the navigation in code (by using the Click event handler). So I'm using a HyperlinkButton and setting the NavigateUri to an empty string and setting the Click handler.
But the problem is that the browser tried to download the entire .xbap as a file download, presumably the empty NavigateUri mean "root".
Is there any way I can re-use the HyperLinkButton class (for visuals) but perform the actual navigation / or action in the Click method.
Open expression blend.
Right click on hyperlink button -> Edit style -> Edit copy
Change TargetType="HyperlinkButton" to TargetType="Button"
Use this style with any button.
Also, I have no problem with code
<HyperlinkButton Content="HyperlinkButton" Click="hb_Click"/>
I have a navigation app with 5 pages. I also have a usercontrol with 3 radio buttons. This usercontrol is used by all 5 pages in my app. By default the first radio button is selected. However if the user clicks the 3rd radio button and I go to another page I want my usercontrol to still show that 3rd radio button as selected. How do I go about accomplishing this task?
There are several ways you could do this. Probably the most simple way is to create a class that has a property for the selected item of the radio buttons. Add an instance of this class as a resource to the application and then bind the radio buttons to this static resource.
public class MyState
{
public string SelectedRadioValue {get;set;}
}
In the App.xaml.cs in the Application_Startup add:
var state = new MyState()
Resources.Add("myState", state);
Then in the bindings you can set:
SelectedValue="{Binding Source={StaticResource myState},Path=SelectedRadioValue}"
There are other approaches you could take as well.
Is it possible to show this control outside of the View control? It sounds like it should be placed on the MainPage.xaml outside of the place where the views are displayed. This way the one control is used and its value can be made available to all of the views.
If you are just looking to save the state of the page as the user navigates between pages then the easiest way of accomplishing this is to set:
NavigationCacheMode="Required"
in the first element of the xaml for your page.