Skip to content

964819-Check and change the code snippet misalignment, mistakes and errors in WPF tools controls UG #1816

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions wpf/Menu/Binding-and-DataTemplate-Support.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ public class CustomItemSource : ObservableCollection<ObjectModel>
new ObjectModel("Essential BI Gauge")));
}
}

{% endhighlight %}
{% endtabs %}

Expand Down
1 change: 1 addition & 0 deletions wpf/Menu/Command-Binding-and-Command-Target-Support.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ To use the Command Binding support in an application users have to create a Dele
</shared:MenuItemAdv>
</shared:MenuAdv>


{% endhighlight %}

{% highlight C# %}
Expand Down
203 changes: 103 additions & 100 deletions wpf/Menu/Data-Binding.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,77 +29,76 @@ public class Model
public string Header { get; set; }
public ObservableCollection<Model> SubItems { get; set; }
}

{% endhighlight %}
{% endtabs %}


2. Create a ViewModel class and initialize the items.

{% tabs %}
{% highlight C# %}

public class ViewModel
{
public ViewModel()
{
MenuItems = new ObservableCollection<Model>();
PopulateData();
}

public ObservableCollection<Model> MenuItems { get; set; }

private void PopulateData()
{
Model product = new Model() { Header = "Products" };
PopulateSubSubItems(product);
MenuItems.Add(product);
}

private void PopulateSubSubItems(Model product)
{
Model bi = new Model() { Header = "Business Intelligence" };
Model ui = new Model() { Header = "User Interface" };
Model wpf = new Model() { Header = "WPF" };
Model tools = new Model() { Header = "Tools" };
Model chart = new Model() { Header = "Chart" };
Model grid = new Model() { Header = "Grid" };
Model diagram = new Model() { Header = "Diagram" };
Model gauge = new Model() { Header = "Gauge" };
Model schedule = new Model() { Header = "Schedule" };
Model edit = new Model() { Header = "Edit" };

wpf.SubItems.Add(tools);
wpf.SubItems.Add(chart);
wpf.SubItems.Add(grid);
wpf.SubItems.Add(diagram);
wpf.SubItems.Add(gauge);
wpf.SubItems.Add(schedule);
wpf.SubItems.Add(edit);

Model sl = new Model() { Header = "Silverlight" };

ui.SubItems.Add(wpf);
ui.SubItems.Add(sl);

Model reporting = new Model() { Header = "Reporting" };

product.SubItems.Add(bi);
product.SubItems.Add(ui);
product.SubItems.Add(reporting);
}
public ViewModel()
{
MenuItems = new ObservableCollection<Model>();
PopulateData();
}
public ObservableCollection<Model> MenuItems { get; set; }

private void PopulateData()
{
Model product = new Model() { Header = "Products" };
PopulateSubSubItems(product);
MenuItems.Add(product);
}

private void PopulateSubSubItems(Model product)
{
Model bi = new Model() { Header = "Business Intelligence" };
Model ui = new Model() { Header = "User Interface" };
Model wpf = new Model() { Header = "WPF" };
Model tools = new Model() { Header = "Tools" };
Model chart = new Model() { Header = "Chart" };
Model grid = new Model() { Header = "Grid" };
Model diagram = new Model() { Header = "Diagram" };
Model gauge = new Model() { Header = "Gauge" };
Model schedule = new Model() { Header = "Schedule" };
Model edit = new Model() { Header = "Edit" };

wpf.SubItems.Add(tools);
wpf.SubItems.Add(chart);
wpf.SubItems.Add(grid);
wpf.SubItems.Add(diagram);
wpf.SubItems.Add(gauge);
wpf.SubItems.Add(schedule);
wpf.SubItems.Add(edit);

Model sl = new Model() { Header = "Silverlight" };

ui.SubItems.Add(wpf);
ui.SubItems.Add(sl);

Model reporting = new Model() { Header = "Reporting" };

product.SubItems.Add(bi);
product.SubItems.Add(ui);
product.SubItems.Add(reporting);
}
}

{% endhighlight %}
{% endtabs %}


3. Create a ViewModel instance and use it as DataContext for the root window.

{% tabs %}
{% highlight xaml %}

<Window.DataContext>
<local:ViewModel/>
<local:ViewModel/>
</Window.DataContext>

{% endhighlight %}
Expand All @@ -111,16 +110,16 @@ public class ViewModel
{% highlight xaml %}

<syncfusion:MenuAdv ItemsSource="{Binding MenuItems}">
<syncfusion:MenuAdv.ItemTemplate>
<HierarchicalDataTemplate ItemsSource="{Binding SubItems}">
<TextBlock Text="{Binding Header}" />
</HierarchicalDataTemplate>
</syncfusion:MenuAdv.ItemTemplate>
<syncfusion:MenuAdv.ItemTemplate>
<HierarchicalDataTemplate ItemsSource="{Binding SubItems}">
<TextBlock Text="{Binding Header}" />
</HierarchicalDataTemplate>
</syncfusion:MenuAdv.ItemTemplate>
</syncfusion:MenuAdv>

{% endhighlight %}
{% endtabs %}

Implementing the above code will generate the following control.

![Data-Binding_images1](Data-Binding_images/Data-Binding_img1.png)
Expand All @@ -137,68 +136,72 @@ An XML file can also be used as _ItemsSource_ for the MenuAdv control. The follo
{% highlight xaml %}

<Categories>
<Root Name="Products">
<SubItem Name="User Interface">
<SubItem Name="ASP .NET"/>
<SubItem Name="ASP .NET MVC"/>
<SubItem Name="WPF">
<SubItem Name="Tools"/>
<SubItem Name="Chart"/>
<SubItem Name="Grid"/>
<SubItem Name="Diagram"/>
<SubItem Name="Gauge"/>
<SubItem Name="Schedule"/>
<SubItem Name="Edit"/>
</SubItem>
<SubItem Name="Silverlight"/>
<SubItem Name="Mobile MVC"/>
<SubItem Name="Windows Phone"/>
<SubItem Name="Windows Forms"/>
</SubItem>
<SubItem Name="Business Intelligence">
<SubItem Name="WPF"/>
<SubItem Name="ASP.NET"/>
<SubItem Name="ASP.NET MVC"/>
<SubItem Name="Silverlight"/>
</SubItem>
<SubItem Name="Reporting">
<SubItem Name="WPF"/>
<SubItem Name="Windows Forms"/>
</SubItem>
</Root>
</Categories>

<Root Name="Products">
<SubItem Name="User Interface">
<SubItem Name="ASP .NET"/>
<SubItem Name="ASP .NET MVC"/>
<SubItem Name="WPF">
<SubItem Name="Tools"/>
<SubItem Name="Chart"/>
<SubItem Name="Grid"/>
<SubItem Name="Diagram"/>
<SubItem Name="Gauge"/>
<SubItem Name="Schedule"/>
<SubItem Name="Edit"/>
</SubItem>
<SubItem Name="Silverlight"/>
<SubItem Name="Mobile MVC"/>
<SubItem Name="Windows Phone"/>
<SubItem Name="Windows Forms"/>
</SubItem>

<SubItem Name="Business Intelligence">
<SubItem Name="WPF"/>
<SubItem Name="ASP.NET"/>
<SubItem Name="ASP.NET MVC"/>
<SubItem Name="Silverlight"/>
</SubItem>

<SubItem Name="Reporting">
<SubItem Name="WPF"/>
<SubItem Name="Windows Forms"/>
</SubItem>

</Root>
</Categories>

{% endhighlight %}
{% endtabs %}

2. Add XmlDataProvider for the above XML document.

{% tabs %}
{% highlight xaml %}

<XmlDataProvider Source="Data.xml"
x:Key="xmlSource" XPath="Categories"/>

x:Key="xmlSource" XPath="Categories"/>
{% endhighlight %}
{% endtabs %}


3. Set ItemsSource property for the MenuAdv.

{% tabs %}
{% highlight xaml %}

<syncfusion:MenuAdv ItemsSource="{Binding Source={StaticResource xmlSource}, XPath=Root}">
<syncfusion:MenuAdv.ItemTemplate>
<HierarchicalDataTemplate ItemsSource="{Binding XPath=SubItem}">
<TextBlock Text="{Binding XPath=@Name}" />
</HierarchicalDataTemplate>
</syncfusion:MenuAdv.ItemTemplate>
</syncfusion:MenuAdv>

<syncfusion:MenuAdv.ItemTemplate>
<HierarchicalDataTemplate ItemsSource="{Binding XPath=SubItem}">
<TextBlock Text="{Binding XPath=@Name}" />
</HierarchicalDataTemplate>
</syncfusion:MenuAdv.ItemTemplate>
</syncfusion:MenuAdv>
{% endhighlight %}
{% endtabs %}


This will create the following MenuAdv control.

![Data-Binding_images2](Data-Binding_images/Data-Binding_img2.png)
Expand Down
1 change: 1 addition & 0 deletions wpf/Menu/InputGestureText-Support.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ The value assigned by using the InputGestureText property will be displayed in M
<shared:MenuItemAdv Header="Build" />
</shared:MenuAdv>


{% endhighlight %}

![InputGestureText-Support_img1](InputGestureText-Support_images/InputGestureText-Support_img1.png)
Expand Down
1 change: 0 additions & 1 deletion wpf/Menu/Orientation-Support.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ When the ExpandMode property is set to ExpandOnClick, you can open the submenu o
</shared:MenuItemAdv>
<shared:MenuItemAdv Header="Edit"/>
</shared:MenuAdv>

{% endhighlight %}

### Properties
Expand Down