I am using syncfusion: menuItemAdv control for showing a hierarchical menu items for an applications.
OnMouseOver or OnMouseClicked(ExpandMode Property)it shows the sub items on mouse hover a menu items. But It doesn't disappear that list on mouse leave. However, If I click anywhere else on the windows(lost focus probably),then it cleans the sub menu item.
So, Instead of clearing the sub menu items on lost focus. I want to do that on mouse leave as user might open any other application without causing lost focus event and might get confused. So, I want to clear the item list on mouse leave.
I know, I can write a behavior and can hook it's on mouse leave event but I don't know how to clean that list. As there is no method exposed from this library. tempering with item source might screw something.
Any help is appreciated.
xaml is as following
<Window x:Class="WpfApp1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:WpfApp1"
xmlns:syncfusion="http://schemas.syncfusion.com/wpf"
mc:Ignorable="d"
Title="MainWindow" Height="350" Width="525">
<Window.DataContext>
<local:MainWindowVM></local:MainWindowVM>
</Window.DataContext>
<Grid>
<syncfusion:MenuAdv Width="300" Height="40" ItemsSource="{Binding League}" ExpandMode="ExpandOnMouseOver">
<syncfusion:MenuAdv.ItemTemplate >
<HierarchicalDataTemplate DataType="local:MenuList" ItemsSource="{Binding Teams}" >
<StackPanel Orientation="Vertical" VerticalAlignment="Top" >
<Label Content="{Binding Name}" Height="Auto" FontFamily="Arial" FontSize="12" VerticalAlignment="Top" Margin="0,3,0,0" VerticalContentAlignment="Center"/>
</StackPanel>
</HierarchicalDataTemplate>
</syncfusion:MenuAdv.ItemTemplate>
</syncfusion:MenuAdv>
</Grid>
</Window>
We have checked the reported behavior and considered this as bug. The fix for this bug will be included in our volume 3 SP2 release which is scheduled to be rolled out by end of September.
Regards,
Durga S.
Related
When I try adding more than one element to my WPF form in the editor in VC#2013, the previous element disappears. In the end, I can't have more than one item in the form. I've already written some code so I'd prefer not starting again from scratch. The form has nothing special besides being borderless, fullscreen and starting maximized.
This is the XAML code for the form right now:
<Window x:Class="queue_bigscreen.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="1080" Width="1920" WindowStyle="None" ResizeMode="NoResize" WindowState="Maximized" Background="#FF9EA7CD">
<Label x:Name="nowServingLabel" Content="0" Margin="42,56,1160,131" Foreground="White" Height="893" FontSize="700" HorizontalContentAlignment="Center">
<Label.Effect>
<DropShadowEffect ShadowDepth="13"/>
</Label.Effect>
</Label>
</Window>
And this is what I get after I select a textbox and try adding it to the form:
<Window x:Class="queue_bigscreen.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="1080" Width="1920" WindowStyle="None" ResizeMode="NoResize" WindowState="Maximized" Background="#FF9EA7CD">
<TextBlock HorizontalAlignment="Left" Margin="1332,382,0,0" TextWrapping="Wrap" Text="TextBlock" VerticalAlignment="Top"/>
As you can see, the label disappears, and the textbox I added in turn disappears if I try adding something else. Am I doing something wrong or is it a known bug?
You need to put the items in a container. Window can only have a single root element, so to get multiple elements on the form, you need to have an element that allows children.
The closest to Windows Forms Form would be Grid. You can then put controls in that, with absolute and relative positioning. It's also the default, so I assume you accidentally deleted it from your XAML (or by being too aggressive with pressing delete in the designer).
Example form with a label and a textbox:
<Window x:Class="WpfApplication1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid>
<Label Content="Label" HorizontalAlignment="Left" Margin="23,30,0,0" VerticalAlignment="Top"/>
<TextBox HorizontalAlignment="Left" Height="23" Margin="66,32,0,0" TextWrapping="Wrap" Text="TextBox" VerticalAlignment="Top" Width="120"/>
</Grid>
</Window>
I'm used to create my forms with the designer, and modifying the XAML manually only when needed.
Even though the extended toolkit is a fantastic library, it still lacks integration with Visual Studio's designer. Can, by any mean, the toolkit's controls be displayed in the designer (not the toolbox), like standard controls? And if not, is there an explanation?
For now, the toolkit's controls are just blank and unselectable with simple clicks.
NOTE: It seems that the issue happens with container components (like BusyIndicator and Wizard/WizardPage) only.
EDIT: Here's some of my XAML. With this, I can see the wizard's first page, but no obvious way to see the others. If I put my Wizard in a BusyIndicator, can't see a thing at all.
<Window x:Class="MyProgram.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:MyProgram"
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
Title="My Program" Height="477" Width="688" MinWidth="688" MinHeight="478">
<xctk:Wizard x:Name="wizard" FinishButtonClosesWindow="True" Next="wizard_Next">
<xctk:WizardPage Name="Intro_Page" Title="ABC" Description="abc" NextPage="{Binding ElementName=Second_Page}" Enter="disallowNext">
<xctk:WizardPage.Content>
<Grid>
<Label Content="abc" HorizontalAlignment="Center" Margin="0,54,0,87" Name="intro_lbl" VerticalAlignment="Center" Grid.Column="1" Padding="5" HorizontalContentAlignment="Center" Height="28" IsEnabled="False" />
</Grid>
</xctk:WizardPage.Content>
</xctk:WizardPage>
<xctk:WizardPage Name="Second_Page" Title="DFG" Description="dfg" NextPage="{Binding ElementName=Last_Page}">
<xctk:WizardPage.Content>
<Grid Name="grid">
<TextBox Grid.Column="1" Height="23" HorizontalAlignment="Stretch" Name="txt_second" VerticalAlignment="Center" />
</Grid>
</xctk:WizardPage.Content>
</xctk:WizardPage>
<xctk:WizardPage Name="Last_Page" PageType="Interior"
Title="Last Page"
Description="This is the last page in the process"
CanFinish="True" />
</xctk:Wizard>
</Window>
I know this answer comes late, but yesterday I was stumbling myself over this problem and maybe it is useful for others who land here.
I solved it by creating an own control derived from WizardPage.
Just Create a new UserControl, include the Xceed.Wpf.Toolkit namespace and change the Type from UserControl to xctk:WizardPage in the xaml file as well as in the code-behind file.
<xctk:WizardPage x:Class="WizardTest.MyWizardPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:xctk="clr-namespace:Xceed.Wpf.Toolkit;assembly=Xceed.Wpf.Toolkit"
xmlns:local="clr-namespace:WizardTest"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<Grid>
<TextBlock>Hello World!</TextBlock>
</Grid>
</xctk:WizardPage>
Now you can create your UI using the VisualStudio Designer.
To place your page in the wizard, simply put an object of you derived page into its items:
<xctk:Wizard>
<local:MyWizardPage Title="My Wizard Page"/>
</xctk:Wizard>
You can use Bindungs in your costum page out of the box because DataContext of the MyWizardPage object is set automatically to the wizards DataContext (which inherits from the Window DataContext if not explicitly given)
SOLUTION here
I was asked to emulate a windows forms context menu using a WPF window. I created a window when the user clicked a certain region, but that window got minimized to the task bar instantly. I need it to stay on top of other windows at least until it loses focus or is deactivated. Its window style is none, and it doesn't matter whether its show in taskbar property is true or false. Similar questions exist on SO, but they don't seem to solve anything in my case. Why this odd behavior? Is there a fix for it?
<Window x:Class="InterceptRouteWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" mc:Ignorable="d" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" Width="200" ResizeMode="NoResize" SizeToContent="Height" ShowInTaskbar="False" Loaded="Window_Loaded" WindowStyle="None" Height="auto" Deactivated="Window_Deactivated">
<StackPanel Height="auto" Name="stackPanel1" Width="200" Background="WhiteSmoke">
<Separator Height="5" FlowDirection="LeftToRight">
<Separator.Background>
<SolidColorBrush />
</Separator.Background>
</Separator>
</StackPanel>
</Window>
So it's a simple window. The way I invoke it:
IRWindow = gcnew InterceptRouteWindow(routes, fpId, offsetPoint.x, offsetPoint.y);
GetMainFrame()->IRWindow->Show();
This is triggered by a click event inside an older app, a mixture of MFC and WindowsForms.. not my code, I had to obey their design and use WPF where I could.
I need my silverlight button to call a specific method, but my button doesn't have any click property. The Intellisense shows "clickmode" but no "click"
I'm definitely using the System.Windows.Controls.Button control
Here's my code for the xaml file
<UserControl
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:Telerik_Windows_Controls="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Charting" x:Class="..."
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="400">
<Grid x:Name="LayoutRoot" Background="White">
<Telerik_Windows_Controls:RadChart Name="radChart" Content="RadChart" Margin="78,47,0,0" d:LayoutOverrides="Width, Height"/>
</Grid>
<Button Content="Button" HorizontalAlignment="Left" Margin="8,8,0,0" VerticalAlignment="Top" Width="75"/>
</UserControl>
A WPF button has an "OnClick" event, or a "Command" property. You may find this link useful: WPF Commanding Overview
Silverlight's Button does have an event called Click, defined in ButtonBase, see the MSDN API documentation. So you might write XAML like:
<Button Content="Button" ... Click="My_Event_Handler"/>
However, have a look at Commanding as referenced by the other answer for the "nice" way to do things (Button's Command property).
Normally, If i use the button in C# Windows form, and if the button text is too long, it will go to next line. (Eg. Very Happy, Happy will go to next line). But When i use wpf app in expression blend, the text will be truncated even though i set the auto size to false. (Eg. Very Happy, Happy will be truncated). Any advice would be really appreciated. Thank you.
You need to place a TextBlock inside your button and set the TextWrapping attribute to Wrap.
Example:
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="WpfApplication1.MainWindow"
x:Name="Window"
Title="MainWindow"
Width="640" Height="480">
<Grid x:Name="LayoutRoot">
<Button HorizontalAlignment="Left" VerticalAlignment="Top" Width="40" Height="40">
<TextBlock Text="Very Happy" TextWrapping="Wrap" />
</Button>
</Grid>
</Window>