I have a I want to add The toolbar is an item control, so it can define the items defined in item / item resources with "container" The "Wrap" wants to contain container is a UIElement that can be used to display items. For example in the case of a list box, the container is a ListBoxItem. If an item is of the appropriate type, it can also be its own container. This setup allows you to pass a list of strings to list the list, and it's properties and support selection, keyboard navigation, styling etc. In the case of the toolbar, it really expects that the item already has a container (i.e. UIElement). If the item is not UIElement, then it wraps it with ContentPresenter. Now, the Datamapplet selector is used by the container to determine how to use it. But you need items for a button, toggle button, separator etc. You are suggesting that you should add a container to the displayed data container by the container. There is also a style problem, which can be seen with this simple example: Above the toolbar buttons at the top as if they were not in Toolbar. Buttons given in the toolbar on the bottom will get a "toolbar" look. It also goes for the separator. You can also manually apply the style: You will have the same problem with different ones. You have to manually apply the style in this way: You should be able to use the above datatyme in your Datamappletschiller, as you do with the button. toolbar a bound
item source , I use I am setting the
DataTemplateSelector at the
DataTemplate runtime (i.e.
button /
ToggleButton ).
separator DataTemplate , how do I do this?
& lt; Window x: Class = "testWPF.MainWindow" xmlns = "http://schemas.microsoft.com/winfx/2006/xaml/presentation" Xmlns: x = "http://schemas.microsoft.com/winfx/2006/ Xaml "xmlns: system =" clr-namespace: system; assembly = mscorlib "title =" main "height =" 500 "width =" 500 "& gt; & Lt; DocPanel Last ChildFill = "False" & gt; & Lt; Toolbar DockPanel.Doc = "Top" & gt; & Lt; ToolBar.ItemTemplate & gt; & Lt; DataTemplate & gt; & Lt; Button content = "{binding}" /> & Lt; / DataTemplate & gt; & Lt; /ToolBar.ItemTemplate> & Lt; System: String & gt; Test1 & lt; / System: String & gt; & Lt; System: String & gt; Test2 & lt; / System: String & gt; & Lt; / Toolbar & gt; & Lt; Toolbar DockPanel.Doc = "Top" & gt; & Lt; Button & gt; Test1 & lt; / Button & gt; & Lt; Button & gt; Test2 & lt; / Button & gt; & Lt; / Toolbar & gt; & Lt; / DockPanel & gt; & Lt; / Window & gt;
& lt; Window x: Class = "TestWPF.MainWindow" xmlns = "http: /sschems.microsoft.com/winfx/2006/xaml/presentation" xmlns: x = "http://schemas.microsoft.com/winfx/2006/ Xaml "xmlns: system =" clr-namespace: system; assembly = mscorib "title =" main "height =" 500 "width =" 500 "& gt; & Lt; DocPanel Last ChildFill = "False" & gt; & Lt; Toolbar DockPanel.Doc = "Top" & gt; & Lt; ToolBar.ItemTemplate & gt; & Lt; DataTemplate & gt; & Lt; Button content = "{binding}" style = "{static resource {x: static toolbar.button steleke}}" /> & Lt ;! - Add Style Attributes - & gt; & Lt; / DataTemplate & gt; & Lt; /ToolBar.ItemTemplate> & Lt; System: String & gt; Test1 & lt; / System: String & gt; & Lt; System: String & gt; Test2 & lt; / System: String & gt; & Lt; / Toolbar & gt; & Lt; Toolbar DockPanel.Doc = "Top" & gt; & Lt; Button & gt; Test1 & lt; / Button & gt; & Lt; Button & gt; Test2 & lt; / Button & gt; & Lt; / Toolbar & gt; & Lt; / DockPanel & gt; & Lt; / Window & gt;
DataTemplate x: key = "Mysparent Template" & gt; & Lt; Separator Style = "{static resource {x: static toolbar. SeparatorStyleKey}}" /> & Lt; / DataTemplate & gt;
Comments
Post a Comment