Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 2 years ago.
Improve this question
I'm developing a vb.net WPF application (not using MVVM) that contains an AvalonDock LayoutAnchorable. What I want to know is, is there a way to remove the built-in Down-Arrow combo button that provides docking options from the LayoutAnchorable?
I do not think that there is an option to hide the drop-down button completely out-of-the-box. The anchorables do not seem to provide any properties or methods for hiding the button or customizing the header template easily.
However, you can remove the button for all anchorables by modifying the AnchorablePaneTitle style. You can find the default styles depening on your theme on GitHub in one of the Xceed.Wpf.AvalonDock.Themes.* directories. The styles are defined in Theme.xaml. You most likely use Aero, if you did not specify anything else.
Copy the style, e.g. Aero, to a resource dictionary in scope or the application resources. Then you can go to the drop-down button definition and set its Visibility to Collapsed. Do not delete this part, it is easier to simply hide it.
<xcad:DropDownButton x:Name="MenuDropDownButton"
Visibility="Collapsed"
... />
Keep in mind that this is not an easy edit, as it requires you to adapt the XML namespaces to the ones that you have imported in your XAML file and adapting the file paths to point to the right assembly, e.g.:
avalonDockProperties:Resources.Anchorable_BtnAutoHide_Hint would become xcad:Resources.Anchorable_BtnAutoHide_Hint for me, as I have added the corresponding namespce as xmlns:xcad="http://schemas.xceed.com/wpf/xaml/avalondock"
The file path Images/PinAutoHide_Dark.png is only valid in the source assembly, so it would become pack://application:,,,/Xceed.Wpf.AvalonDock.Themes.Aero;component/Images/PinClose_Dark.png
``
You could also reset the AnchorableContextMenu. It would prevent the context menu on the anchorables from showing up. If you did not modify the template, it would also prevent the drop-down button from showing any menu items, but the drop-down button would still be visible and clickable.
<xcad:DockingManager AnchorableContextMenu="{x:Null}">
Look at this image for a comparsion of the original and the modified template.
Related
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 8 years ago.
Improve this question
I want to create a custom control using Infragistics UltraGrid control. I want to add a button on top of the UltraGrid which exports data as excel. You can get better idea by viewing below image.
This grid is used many times in my project so that i need it in a user control. I have tried to create it but when i add this control in my project i cannot access all actual properties of that UltraGrid.
please help...
You are creating a composite control. Normally this means that you can't access the composing controls from the form where you want to position your usercontrol. Usually you need to provide the code to access the underlying properties and events of the controls that compose your UserControl.
For example, supposing that you want to change the caption of the UltraWinGrid inside your user control, you should write a get/set property like this in the code of the UserControl.
public string GridText
{
get
{
return ultraGrid1.Text;
}
set
{
ultraGrid1.Text = value;
}
}
As you can imagine, this is not a trivial task with a control like the Infragistics UltraWinGrid that has probably thousands of properties. Not to mention the long list of events.
See here a tutorial from Microsoft about building a Composite Control and that explain the problem with properties of the underlying controls.
A simple workaround (NOT RECOMMENDED) could be to change the property Modifiers of the UltraWinGrid and of the button from Private to Public. In this way the grid reference is available from the properties of the UserControl and you can program it as before.
userControl1.ultraGrid1.Text = "My User Control";
However this is not recommended because you give full access to the composing controls and this, in certain situations, could be not desiderable. It largely depends on your using scenario.
First of all, I'm new to XAML / C# (am iOS/Android programmer) so please bear with me instead of immediately voting down. My app has some GridViews that contain buttons. A lot of these buttons are similar and I would like to refactor this. For simplicity let's say my buttons are just Rectangles with a given color. This color might come from the Item class that defines the particular item in the GridView, or it might be hardcoded. I want the rectangle to change color on hover and pressed states. I want these colors to be parameters as well.
What is the best way to achieve this?
I tried to make a Button subclass but somehow I couldn't access the dependency properties in the VisualStateManager
I tried to write stuff in the code-behind but then I wasn't sure how to delegate the click command to the ViewModel class.
Could someone give me a small working example?
Thanks
You can do this with style templates.
In the Visual Studio designer, right-click on your button and then select Edit Template and then select Edit a Copy....
You will then be prompted to name your new style and also for which file to store it in. For now, just give it a unique name such as MyButtonStyle, and select the current file.
Visual Studio will then add a copy of the style to the current xaml document, and will update your button to use the new style.
<Button x:Name="Download" Style="{StaticResource MyButtonStyle}"></Button>
After this, you can update the new style including changing the colors for the different visual states such as hover or clicked.
You can then proceed to use the new style in other buttons in the same document. To use the style in multiple xaml documents, you have to pull it out into a common resource file.
So you want to adjust your button using custom properties. This is a good time to use a custom control. You can create whatever dependency properties you want and adjust your layout in your code. http://timheuer.com/blog/archive/2012/03/07/creating-custom-controls-for-metro-style-apps.aspx
I'm developing a WPF application in C# and was thinking about implementing a custom UI element accross various windows.
I would like to have a minimized tray (only about 4px visible) that expands after clicking on an icon next to the tray. The expanded version would show all controls and would minimize when I click the icon again. I created a quick HTML concept to clarify things.
I know I could put a stackpanel and button in my application and making both of them move up when I click the button, but then I would need to duplicate the code a lot.
Though I'm experienced with C#, I'm fairly new to WPF interface development/templates, but I'm sure there has to be a way so I can use that UI element accross my application without needing to copy/paste a lot of lines of code in my form class file.
I hope someone can help me, or at least point me in the right direction.
There are three ways to customize your elements.
1 If you only need visual modifications you can use styles to change the appearance of the .net default controls. You can even override / extend the default templates.
2 If you want custom logic in a control you can create a custom control. The framework brings a lot of "primitives" to build upon. Examples are ContentControl or HeaderedContentControl. Say you want to build a custom expander control you can inherit your custom control from HeaderedContentControl which provides you with Header and Content properties and you just have to implement the toggling logic yourself.
CustomControls are a good choice if you want to build basic functionality which can be used throughout your application. They can be themed/styled depending on the use case, too (see 1).
3 If you want to compose different controls into one control you can create a UserControl. User controls are composed using XAML. Most top level controls are user controls driven by a view model.
Your case can be build using a Popup and ToggleButton or an Expander.
The decision depends on the desired behavior. If you want the opened panel to move following content down you need a expander. If you want a dropdown like functionality you need popup.
If you use a popup just bind the IsPopupOpen Property to IsChecked of the ToggleButton and set PopupStaysOpen = false to wire the button to your popup.
If you use an expander control you should create a style which can be applied to all equal expanders in your application to minimize the required XAML in each view.
How about using Expander Control?
There's a control called an Expander that is perfect for this. You'll have to style it to look like you want, however it has the functionality you want built-in.
I am trying to develop a Customize TabControl in which I'll divide the Whole TabControl into three Parts:
1)Tab Header
2)Common Region(for all Tab) and
3)Tab Content region for specific Tab
Update:
Please provide your best answers or samples if you have then, any type of help will be appreciated.
Thanks in Advance
You can overwrite the TabControl Template to be anything you want, including making it have a static region that stays visible regardless of which tab is selected.
Within the Template, I normally use a panel with IsItemsHost=True to define where the "Tab" portion of the tab control will be displayed and <ContentPresenter ContentSource="SelectedContent" /> where I want the selected tab content to be displayed.
The TabControl.ItemTemplate can also be overwritten to further define your Tabs, and TabControl.ItemContainer can be overwritten to modify just the TabContent part of the TabControl.
Hmm ... I don't quite understand why one would do this, but if I were you I would implement this using WPF.
I would implement the tab header as a StackPanel filled with Buttons (their style obviously needs to be redone so that it looks like tabs). The content would be a rectangle containing a grid whose content changes on clicking a button. And that's pretty much it for the basic sceleton. I don't understand your Common Region. What is also nice is to add a little "X" inside each tab in order to close it. That can be done with buttons as well.
It might make sense to use Expression Blend to create such a control.
Best wishes,
Christian
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I'm a real dummy at UI building, so I'm wondering - what .NET winforms control would be best to use if aiming to display tweets in a list fashion that updates with like boxes which contain the text of the tweet and its metadata below it. Is there a specific winforms list function for this type of thing? Or do you recommend I look for/use a third party winforms control? Thanks! Hope my question wasn't too silly.
UPDATE: I am getting indication from numerous responses that it would be better to just build a simple winform control myself, but can anyone point me to a tutorial for doing so? Also, if i were to build such a control, does there exist a convenient built-in control for making like a list of custom controls that is scrollable - maybe Panel? Thanks in advance!
I'd build a user control that would display the information for a single tweet. I'd then repeat that user control in a panel.
You could just use the same layout in your user control that is standard for "tweets".
Left justified picture box to display the user image.
LinkLabel for user name.
Label for tweet text.
Update: Here are a couple pages on UserControls
http://msdn.microsoft.com/en-us/library/a6h7e207(VS.71).aspx
http://www.akadia.com/services/dotnet_user_controls.html
Create a usercontrol using the designer and also a Tweet class that is
just a dumb data structure to hold each tweet's information. Also create a Tweet
property on the custom user control that would handle setting the tweet and assigning information
to the standard controls contained in it (Labels, Textboxs, PictureBox, etc).
In the form where you want to host your user control create a panel that is empty. Somewhere in your code you
would do something similar to this code block.
pnlHost.Controls.Clear();
List<Tweet> tweets = new List<Tweet>();
//Populate your collection of tweets here
foreach (Tweet tweet in tweets)
{
TweetControl control = new TweetControl();
control.Tweet = tweet;
pnlHost.Controls.Add(control);
control.Dock = DockStyle.Top;
}
Hi I'd go for a third party grid control from companies like Infragistics, DevExpress or Telerik. Another option would be to build a usercontrol that is able to display one post and put that control into a vb.net repeater control (which ships with the vb.net powerpack). However I'm not sure how good the last solution actually works, as I just read about it, but never tried it.
Try using DataGridView (and a DataTable behind it) and overwrite the CellPainting event to draw the tweets the way you like it.
Edit
I think using a custom control is a bit heavy just to display the tweets. Basically this depends on the desired functionality of the displayed tweets - what would you like to do with them. For example, if you just want the user to click the tweet and then redirect him to some webpage in the browser then the DataGridView will do just fine since you can attach this action to the CellClick event. Plus you already have the sorting/searching capabilities of the DataTable (and the related DefaultView)behind it. Hell, you can even attach a ContextMenuStrip to the tweet and have unlimited options with the RightClick.
On the other hand if you need some functionality that is not available in the DataGridView (for example, you would like 5 different buttons at the bottom of the tweet and 3 checkboxes on the right) then the custom control would do you better because you could build practically everything you wanted. In this case OG explains this nicely.
Try listbox, it's easy to use and seems like it will suit your needs.