What is the exact difference between ToolBarPanel and ToolBarTray in wpf? - wpf

What is the exact difference between ToolBarPanel and ToolBarTray in WPF?

Here you are
The ToolBar uses a ToolBarPanel and a ToolBarOverflowPanel in its ControlTemplate. The ToolBarPanel is responsible for the layout of the items on the toolbar. The ToolBarOverflowPanel is responsible for the layout of the items that do not fit on the ToolBar. For an example of a ControlTemplate for a ToolBar, see
https://learn.microsoft.com/en-us/dotnet/desktop/wpf/controls/toolbar-overview?view=netframeworkdesktop-4.8
ToolBarPanel Class
XAML
<ToolBarTray Background="White">
<ToolBar Band="1" BandIndex="1">
<Button>
<Image Source="toolbargraphics\cut.bmp" />
</Button>
<Button>
<Image Source="toolbargraphics\copy.bmp" />
</Button>
<Button>
<Image Source="toolbargraphics\paste.bmp" />
</Button>
<Button>
<Image Source="toolbargraphics\undo.bmp" />
</Button>
<Button>
<Image Source="toolbargraphics\redo.bmp" />
</Button>
<Button>
<Image Source="toolbargraphics\paint.bmp" />
</Button>
<Button>
<Image Source="toolbargraphics\spell.bmp" />
</Button>
<Separator/>
<Button ToolBar.OverflowMode="Always">
<Image Source="toolbargraphics\save.bmp" />
</Button>
<Button ToolBar.OverflowMode="Always">
<Image Source="toolbargraphics\open.bmp" />
</Button>
<Button ToolBar.OverflowMode="Always">
<Image Source="toolbargraphics\print.bmp" />
</Button>
<Button ToolBar.OverflowMode="Always">
<Image Source="toolbargraphics\preview.bmp" />
</Button>
</ToolBar>
</ToolBarTray>

Related

A value of type toolbar cannot be added to a collection or dictionary of type Collection

I get the error described in the title using Toolbar(s) in a ToolBarTray like the following:
<ToolBarTray DockPanel.Dock="Top">
<ToolBar>
<Button Command="New" Content="New" />
<Button Command="Open" Content="Open" />
<Button Command="Save" Content="Save" />
</ToolBar>
<ToolBar>
<Button Command="Cut" Content="Cut" />
<Button Command="Copy" Content="Copy" />
<Button Command="Paste" Content="Paste" />
</ToolBar>
</ToolBarTray>
I can compile the program, it works perfectly, but I continue to get the error in Visual Studio.
Looks like I'm missing something, but I have no clue of what it is...
Any idea? Thanks in advance!
Edit Problem magically disappeared. The only thing I can say is that this morning I did a reboot (I'm not sure if I did reboots while having the error: I often hybernate my machine).

Wix installer- Change Combobox Value Based on radio button change

In the Below Code i tried to change Combo box value when we selecting Radiobutton , but it is not changing
<Control Id="radioButtonGroupBox1" Type="RadioButtonGroup"
Property="INSTALL_CUSTOMSCALE" Height="34" Width="64" X="48" Y="99">
<RadioButtonGroup Property="INSTALL_CUSTOMSCALE">
<RadioButton X="5" Y="2" Height="15" Width="56"
Text="Custom" Value="Custom" />
<RadioButton X="5" Y="18" Height="15" Width="56"
Text="Scaleout" Value="Scaleout" />
</RadioButtonGroup>
<Publish Property="CUSTOM_OPTION" Value="Server1" ></Publish>
</Control>
<Control Id="cmbCustomOption" Type="ComboBox" Property="CUSTOM_OPTION"
Height="16" Width="166" X="116" Y="101" >
<ComboBox Property="CUSTOM_OPTION">
<ListItem Text="Select..." Value="Select..." />
<ListItem Text="Server1" Value="Server1" />
<ListItem Text="Server2" Value="Server2" />
<ListItem Text="Server3" Value="Server3" />
<ListItem Text="Server4" Value="Server4" />
</ComboBox>
</Control>
And Also how to set Combobox non editable(readonly)
To set combobox non editable just add "ComboList = yes"
<Control Id="cmbCustomOption" Type="ComboBox" Property="CUSTOM_OPTION" Height="16"
Width="166" X="116" Y="101" ComboList="yes">
<ComboBox Property="CUSTOM_OPTION">
<ListItem Text="Select..." Value="Select..." />
<ListItem Text="Server1" Value="Server1" />
<ListItem Text="Server2" Value="Server2" />
<ListItem Text="Server3" Value="Server3" />
<ListItem Text="Server4" Value="Server4" />
</ComboBox>
</Control>

WPF: Element Justification

Is there a way to justify three or more elements in WPF along the window size,
in such a way that it would look like this:
[button] [button] [button] [button]
________________________________________________________
I tried searching for ways using dockpanel/stackpanel, but they only seem to use two elements (for attaching one to the left, and one to the right, for example.)
here is a sample using UniformGrid
<UniformGrid Columns="4">
<Button Content="1" />
<Button Content="2" />
<Button Content="3" />
<Button Content="4" />
</UniformGrid>
if you do not want to fix the columns to 4 then fix the rows to 1 and all the buttons will be uniformly spaced
<UniformGrid Rows="1">
<Button Content="1" />
<Button Content="2" />
<Button Content="3" />
<Button Content="4" />
<Button Content="5" />
<Button Content="6" />
</UniformGrid>

WPF ToolBar: How to arrange toolbars at design-time

I've got two Wpf ToolBars in a single ToolBarTray. How to make them fit on two rows?
I noticed users can move them at run-time. Is there a way to get the same behavior at design-time without using two ToolBarTrays ?
To sumarize, at startup, I want this:
instead of that:
Thanks
Use Band and BandIndex to control toolbar layout.
<ToolBarTray Background="White">
<ToolBar Band="1" BandIndex="1">
<Button Content="B1"/>
<Button Content="B2"/>
<Button Content="B3"/>
</ToolBar>
<ToolBar Band="2" BandIndex="1">
<Button Content="B4"/>
<Button Content="B5"/>
</ToolBar>
<ToolBar Band="2" BandIndex="2">
<Button Content="B6"/>
<Button Content="B7"/>
</ToolBar>
</ToolBarTray>

Flowlayout control in Silverlight 4

In silverlight 4 Beta there used to be a contol called flowlayout control.
Now i am not able to see that in the silverlight 4 rc. please let me know if anything needs to be installed to get that control.
Never heard of that in Silverlight or WPF. FlowLayoutPanel was a Windows Forms control. What you can use is the WrapPanel from the Silverlight Toolkit.
<toolkit:WrapPanel Orientation="Horizontal" Width="150">
<Button Content="Hello!" />
<Button Content="Hello!" />
<Button Content="Hello!" />
<Button Content="Hello!" />
<Button Content="Hello!" />
<Button Content="Hello!" />
<Button Content="Hello!" />
<Button Content="Hello!" />
</toolkit:WrapPanel>

Resources