I am trying to create a ToolBar in my WPF application.
I don't want the strip (as shown in the bellow figure) to show up, I just want all the items to be placed in the general area.
I tried setting the ToolBar.OverflowMode to Never ut it doesn't help.
According to Toolbar's control template, there is nothing that can remove that grip. You can set ToolBarTray.IsLocked="True" but this will remove only drag handle from the left hand side. As for the grip you will have to edit default ToolBar template (you can find one in Expression Blend directory, e.g. C:\Program Files\Microsoft Expression\Blend 3\SystemThemes\Wpf\), and remove OverflowGrid from it...
Related
I don't use MUCH the XAML designer, but I appreciate at some time to have the possibility to use, and more, to have the "Properties" windows present to set some properties.
But I would like that when I click on a XAML file, I get the XAML code, without the GUI part. Basically, the Xaml Designer, but not in "split" view.
Is this possible?
I found that it is possible to totally disable the XAML designer, but then:
I don't get the possibility to just switch to this view(well with Open Width, yes)
More important, I don't have the "Properties" windows populated with the properties of the currently selected XAML
I also found that there is a setting with a default view(Tools, Options, XAML Designer, Default Document view: SourceView), but this doesn't work(or I didn't understood), I still get the default split view, even after a VS2015 restart.
So is it possible to keep the XAML designer, but have by default only the XAML displayed?
Easy Way.
Go to Tools -> Options.
and follow the screen shot.
To open .xaml files in XAML-only mode, you need to change the default editor that .xaml files open with. Here's how:
Right click on any .xaml file.
Click on Open with...
Select Source Code (Text) Editor.
Click Set as Default.
Click OK.
That's it. Opening any .xaml file should now open in full XAML view. To get back to the designer, simply press Shift + F7, or Right Click -> View Designer.
The only drawback that I have experienced is that Intellisense doesn't seem to pick up any resources (i.e DynamicResource and StaticResource references) that you may have.
If you still want the Designer running in the background, use the following instructions:
Go to Tools -> Options.
Expand Text Editor -> XAML -> Miscellaneous.
Check the Always open documents in full XAML view checkbox.
This will open all .xaml documents in full XAML view, to switch back to the designer, simply click on the Design tab.
New place XAML Designer options.
screenshot
I am just wondering which ItemsControl they are using, is it something of their own or its a regular ListBox with some styling ?
Here is the screenshot
I am trying to get a similar one, which one you would recommend ?
It's a ListView. If you used Snoop and focus on the PackageManagerWindow then you will see the UIElements that makes up for it. The crosshair only launches Snoop on the dropped window. If you want to focus you need to use CTRL + SHIFT and click the element you want to snoop on.
I'm making a custom dropdown button (since the one included in wpf requires too much hacking to style right). Now that i got the button bit out of the way i need to add the drop down part.
My first thought was to add a stackpanel and use that to contain the items but it gets cut off if it leaves the borders of the grid that the button is in. Next up was the popup primitive, it gets on top of everything nicely enough but position wise it just free floats and i haven't figured out how to make it follow the button it was spawned by. I also tried using contextmenu but that seems to have no positioning controls at all and just sits where the mouse made it..
Anyways wpf is a big package and I'm just getting into it, anybody know which direction i might find what I'm looking for?
Preferred approach normally is to use a Popup. You got two very important properties with a Popup
PlacementTarget and Placement
Setup a binding for PlacementTarget on the Popup to your custom Button and then use Placement to position the Popup accordingly w.r.t to the PlacementTarget(Button)
Placement accepts an enum of type PlacementMode which gives you quite a few options to position the Popup.
I'm wondering how I can extract (get a copy) of the Default Template of a given control using Visual Studio. I know this can be done with Expression Blend (right click a control, "Edit Template" -> "Edit a Copy...") which then copies the default control template in my Xaml. But can this be done with Visual Studio at all?
2015 update with clear instructions
In Visual Studio 2013, you can get the default ControlTemplate of a control in a few simple steps.
In the WPF designer, select the relevant control, or place the mouse cursor on the relevant control in the XAML.
Press F4 to open the Properties Window.
Open the Miscellaneous category to find the Template property, or type Template in the search field at the top of the Window.
Click on the little square to the right of the Template field and select the Convert to New Resource... option:
In the popup dialog, name the new ControlTemplate to be added and decide where you want it to be defined:
Click on the OK button.
EDIT >>>
In Visual Studio 2019 and later, this option seems to be disabled for some reason. A workaround can be found by right-clicking the control in the design view and selecting "Edit Template", then selecting "Edit a Copy...".
From Visual studio - right click the control, choose properties,
In the properties window look for the Template Property and right click it,
choose Extract Value To Resource
That will create a copy of the template in the XAML for you to work on.
Just to update this question, in VS 11 the XAML designer allows you to do this just like Expression Blend.
One thing to keep in mind: if you already have a style defined somewhere that targets the given control then all of the above described options will be disabled. I had the following bit of code in my App.xaml file:
<Application.Resources>
<Style TargetType="Button">
<Setter Property="IsTabStop" Value="False"/>
</Style>
</Application.Resources>
I was pulling my hair out trying to figure out why the edit a copy... and convert to new resource... options described in the other answers were disabled for my Button (which was defined in a completely different file). I commented out the above style code for Button and suddenly both options weren't disabled anymore.
Moral of the story: VS won't generate a style containing a template copy for you if a style already exists for that element anywhere in your code.
In VS19 I wasn't able to do this through properties.
However, I was able to right click the control in design mode Edit Template and Edit a Copy.
As far as I know it's not possible. However, you can use Show Me The Template to view the default template for a given control.
If I have a Xaml Window open, I can goto Resources in the right panel, and see all my DataTemplates. If I right click on one of them, I can select a data template, click edit, then graphically edit my template.
Now that is nice, but, how do I go back to the Window containing the DataTemplate? If I right-click the window in the right hand panel, I can select "view xaml", but there is no option or menu I can find that returns me to the main Window for graphical editing. Where is it?!?
Anyone know how to return?
It's somewhere in the bar above the design view if i remember correctly, it's a path in the hierarchy which you can go up.
Also in the Objects and Timeline toolbar there's an up arrow which brings you back.
(Where it says DataTemplate1 (ContentPresenter Template))