How to add a button in a NavigationView using UWP? - c#

I'm implementing a NavigationView like described is this topic.
Between the nav items (NavigationViewItem) I need to add a simple button, that will just execute an action, it will not navigate anywhere.
Every control I add to nav receives the property to stay selected when clicked, but I need a control that doesn't deselect the current nav, just execute an action.
Does anyone know how to do this or can suggest a solution? Grateful.

but I need a control that doesn't deselect the current nav, just execute an action.
Sure, you could edit the default NavigationView style and insert button into PaneContentGrid, and you could get default NavigationView style from generic.xaml file, then find PaneContentGrid add button like the following (InsertButton).
<SplitView.Pane>
<Grid x:Name="PaneContentGrid" Visibility="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=TemplateSettings.LeftPaneVisibility}">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="0" />
<!-- above button margin + back button space -->
<RowDefinition x:Name="PaneContentGridToggleButtonRow" Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="8" />
<!-- above list margin -->
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="8" />
</Grid.RowDefinitions>
<Grid x:Name="ContentPaneTopPadding" Height="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=TemplateSettings.TopPadding}" />
<Grid Grid.Row="2" Height="{StaticResource PaneToggleButtonHeight}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="{ThemeResource PaneToggleButtonWidth}" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<ContentControl
x:Name="PaneHeaderContentBorder"
Grid.Column="1"
HorizontalContentAlignment="Stretch"
VerticalContentAlignment="Stretch"
IsTabStop="False" />
</Grid>
<Grid
x:Name="AutoSuggestArea"
Grid.Row="3"
Height="{ThemeResource NavigationViewTopPaneHeight}"
VerticalAlignment="Center">
<ContentControl
x:Name="PaneAutoSuggestBoxPresenter"
Margin="{ThemeResource NavigationViewAutoSuggestBoxMargin}"
HorizontalContentAlignment="Stretch"
VerticalContentAlignment="Center"
IsTabStop="False" />
<Button
x:Name="PaneAutoSuggestButton"
Width="{TemplateBinding CompactPaneLength}"
Style="{ThemeResource NavigationViewPaneSearchButtonStyle}"
Visibility="Collapsed" />
</Grid>
<ContentControl
x:Name="PaneCustomContentBorder"
Grid.Row="4"
HorizontalContentAlignment="Stretch"
VerticalContentAlignment="Stretch"
IsTabStop="False" />
<!-- Left nav list -->
<NavigationViewList
x:Name="MenuItemsHost"
Grid.Row="6"
Margin="0,0,0,20"
HorizontalAlignment="Stretch"
IsItemClickEnabled="True"
ItemContainerStyle="{TemplateBinding MenuItemContainerStyle}"
ItemContainerStyleSelector="{TemplateBinding MenuItemContainerStyleSelector}"
ItemTemplate="{TemplateBinding MenuItemTemplate}"
ItemTemplateSelector="{TemplateBinding MenuItemTemplateSelector}"
SelectedItem="{TemplateBinding SelectedItem}"
SelectionMode="Single"
SingleSelectionFollowsFocus="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=TemplateSettings.SingleSelectionFollowsFocus}" />
<ContentControl
x:Name="FooterContentBorder"
Grid.Row="7"
HorizontalContentAlignment="Stretch"
VerticalContentAlignment="Stretch"
IsTabStop="False" />
<Button Grid.Row="7" Content="Command" x:Name="InsertButton"/>
<NavigationViewItem
x:Name="SettingsNavPaneItem"
Grid.Row="8"
Icon="Setting" />
</Grid>
</SplitView.Pane>
If you don't want to edit style, you could also insert button into NavigationView PaneFooter like following
<NavigationView x:Name="nvSample">
<NavigationView.MenuItems>
<NavigationViewItem
Content="Menu Item1"
Icon="Play"
Tag="SamplePage1" />
<NavigationViewItem
Content="Menu Item2"
Icon="Save"
Tag="SamplePage2" />
<NavigationViewItem
Content="Menu Item3"
Icon="Refresh"
Tag="SamplePage3" />
<NavigationViewItem
Content="Menu Item4"
Icon="Download"
Tag="SamplePage4" />
</NavigationView.MenuItems>
<Frame x:Name="contentFrame" />
<NavigationView.PaneFooter>
<Button Content="Click"/>
</NavigationView.PaneFooter>
</NavigationView>

Related

Bindings from Multiple ViewModels in same View WPF MVVM

I have a WPF MVVM project that includes a View which contains several controls.
There is a DockPanel which contains all the controls in the View with DataContext to a MainViewModel Class, and inside of it there is a Grid with DataContext to other object ViewModel which it's property contained in the MainViewModel Class.
Now, in that Grid I have a 2 buttons surrounds with WrapPanel, and the buttons have a Commands to a property which wrote in the MainViewModel Class, and when I pressed on it nothing happens (Because the Grid's DataContext is to other object).
I need the Commands to be stay in the MainViewModel Class, How can I do that?
XAML: (just the relevant parts)
<DockPanel x:Name="MonitorParent" DataContext="{Binding MonitorMainViewModel}" LastChildFill="False" Width="1144" HorizontalAlignment="Left">
.......
<StackPanel>
<ContentControl Visibility="{Binding Path=NoMonitorsMessageVisibility, Converter={StaticResource visibilityConverter}}">
<StackPanel Width="804" Height="574">
<Grid DataContext="{Binding CurrentMonitor}" Margin="10 0" Height="auto">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" MinHeight="23" />
<RowDefinition Height="Auto" MinHeight="23" />
<RowDefinition Height="Auto" MinHeight="23" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="140" />
</Grid.ColumnDefinitions>
<Label Grid.Column="0" Grid.Row="15" Content="Serial Number" x:Name="SerialNumber" />
<WrapPanel DataContext="{Binding MonitorMainViewModel}" HorizontalAlignment="Center" Margin="0,10,0,10" Grid.ColumnSpan="2" Grid.Row="6" >
<Button Content="Add" Width="60" Margin="0,0,40,0" Command="{Binding AddConfidenceCommand}" />
<Button Content="Delete" Width="60" Margin="30,0,0,0" Command="{Binding DeleteConfidenceCommand}"/>
</WrapPanel>
........
</DockPanel
You could use the name of the DockPanel for binding like this:
<DockPanel x:Name="MonitorParent" DataContext="{Binding MonitorMainViewModel}" LastChildFill="False" Width="1144" HorizontalAlignment="Left">
.......
<StackPanel>
<ContentControl Visibility="{Binding Path=NoMonitorsMessageVisibility, Converter={StaticResource visibilityConverter}}">
<StackPanel Width="804" Height="574">
<Grid DataContext="{Binding CurrentMonitor}" Margin="10 0" Height="auto">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" MinHeight="23" />
<RowDefinition Height="Auto" MinHeight="23" />
<RowDefinition Height="Auto" MinHeight="23" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="140" />
</Grid.ColumnDefinitions>
<Label Grid.Column="0" Grid.Row="15" Content="Serial Number" x:Name="SerialNumber" />
<WrapPanel DataContext="{Binding MonitorMainViewModel}" HorizontalAlignment="Center" Margin="0,10,0,10" Grid.ColumnSpan="2" Grid.Row="6" >
<Button Content="Add" Width="60" Margin="0,0,40,0" Command="{Binding ElementName=MonitorParent, Path=DataContext.AddConfidenceCommand}" />
<Button Content="Delete" Width="60" Margin="30,0,0,0" Command="{Binding ElementName=MonitorParent, Path=DataContext.DeleteConfidenceCommand}"/>
</WrapPanel>
........
Try this:
<Button Content="Add" Width="60" Margin="0,0,40,0"
Command="{Binding DataContext.AddConfidenceCommand, ElementName=MonitorParent}" />
Or:
<Button Content="Add" Width="60" Margin="0,0,40,0"
Command="{Binding DataContext.AddConfidenceCommand, RelativeSource={RelativeSource AncestorType=DockPanel}}" />

WPF Grid Rows and ResizeGrip do not anchor correctly

once again after hours of struggle with WPF I need your awesome help.
I have read many different StackOverflows, nonetheless, I cannot seem to get my current situation working and I don't understand why. I have chosen to use a Grid in contrast to a DockPanel and I would like to keep it that way as well. According to what I have read the row definitions are ok, the second row of the template grid should automatically stretch. Unfortunately it does not, as it seems that the last row of the grid does not move away.
This is how my window looks at the moment:
As you can see is the blue row not at the bottom of the window. In fact, the window should not be that long in the first place.
This is the code snippet of my Generic.xaml file that is relevant to the problem.
The way it works is, that I have a Skin with a custom control group:
<!-- Window START-->
<ControlTemplate x:Key="WindowTemplate" TargetType="{x:Type Window}">
<Border BorderBrush="LightGray" BorderThickness="1" Background="Red" Padding="0" VerticalAlignment="Stretch">
<Grid x:Name="WindowRoot" Margin="0" VerticalAlignment="Top" Background="Blue" MouseDown="Window_MouseDown">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="25"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="75"/>
<ColumnDefinition Width="25"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="40" />
<RowDefinition Height="*" />
<RowDefinition Height="25" />
</Grid.RowDefinitions>
<!-- HEADER START-->
<Frame x:Name="header_background" Grid.Column="0" Grid.ColumnSpan="4" Grid.Row="0" Background="#ddd" BorderThickness="0 0 0 1" BorderBrush="#c9c9c9"/>
<Image x:Name="LogoICon" Source="/MTApp;component/Resources/Icon.png" Grid.Column="0" Grid.ColumnSpan="2" HorizontalAlignment="Left" Margin="10 8"/>
<Label x:Name="windowTitle" Grid.ColumnSpan="2" Content="{TemplateBinding Title}" VerticalAlignment="Center" Foreground="#393939" Grid.Row="0" Grid.Column="1" HorizontalAlignment="Center" FontFamily="Segoe UI Regular" FontSize="12"/>
<Grid Grid.Column="2" Grid.ColumnSpan="2" Grid.Row="0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="35"/>
<ColumnDefinition Width="18"/>
<ColumnDefinition Width="19"/>
<ColumnDefinition Width="18"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="10"/>
<RowDefinition Height="20" />
<RowDefinition Height="10" />
</Grid.RowDefinitions>
<Button x:Name="minimizeBtn" Content="0" FontFamily="Marlett" Foreground="#393939" Background="Transparent" BorderThickness="0" Grid.Row="1" Grid.Column="1" Margin="3 0 0 0" Click="minimizeBtn_Click"/>
<Button x:Name="maximizeBtn" Content="2" FontFamily="Marlett" Foreground="#393939" Background="Transparent" BorderThickness="0" Grid.Row="1" Grid.Column="2" Margin="3 0 0 0" Click="maximizeBtn_Click"/>
<Button x:Name="quitBtn" Content="r" FontFamily="Marlett" Foreground="#393939" Background="Transparent" BorderThickness="0" Grid.Row="1" Grid.Column="3" Margin="3 0 0 0" Click="quitBtn_Click"/>
</Grid>
<!-- HEADER END-->
<!-- CONTENT START-->
<ContentPresenter Grid.Column="0" Grid.ColumnSpan="4" Grid.Row="1" Height="Auto"/>
<!-- CONTENT END-->
<!-- FOOTER START-->
<Border x:Name="footer_background" Grid.Column="0" Grid.ColumnSpan="4" Grid.Row="2" Height="25">
<ResizeGrip />
</Border>
<!-- FOOTER END-->
</Grid>
</Border>
</ControlTemplate>
<!-- Window END-->
<Style x:Key="LightSkin_0_1" TargetType="Window">
<Setter Property="WindowStyle" Value="None" />
<Setter Property="AllowsTransparency" Value="True" />
<Setter Property="ResizeMode" Value="CanResizeWithGrip" />
<Setter Property="Template" Value="{StaticResource WindowTemplate}" />
<Style.Triggers>
<DataTrigger Binding="{Binding WindowState}" Value="Maximized">
</DataTrigger>
</Style.Triggers>
</Style>
And my MainWindow.xaml is:
<Window x:Class="UHashIt.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:UHashIt"
mc:Ignorable="d"
Title="Window title"
WindowStartupLocation="CenterScreen"
MinHeight="275"
MinWidth="700"
Width="700"
Style="{DynamicResource LightSkin_0_1}">
<Grid Background="White">
<Grid.RowDefinitions>
<RowDefinition Height="30" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<!-- Menu -->
<Border VerticalAlignment="Top" Padding="5" Background="#f2f2f2" Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="4" BorderThickness="0 0 0 1" BorderBrush="LightGray">
<DockPanel >
<Menu DockPanel.Dock="Left">
<MenuItem Header="File">
<MenuItem Header="Add File" />
<MenuItem Header="Export.." />
<Separator />
<MenuItem Header="Close"/>
</MenuItem>
<MenuItem Header="Help">
<MenuItem Header="Online Documentation" />
<MenuItem Header="About"/>
</MenuItem>
</Menu>
</DockPanel>
</Border>
<!-- Menu End -->
<!-- Content -->
<Grid Grid.Row="1" VerticalAlignment="Stretch">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="25"/>
<ColumnDefinition Width="150*"/>
<ColumnDefinition Width="40"/>
<ColumnDefinition Width="150*"/>
<ColumnDefinition Width="25"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="30" />
<RowDefinition Height="40" />
<RowDefinition Height="30" />
<RowDefinition Height="40" />
<RowDefinition Height="50" />
</Grid.RowDefinitions>
<Label Style="{DynamicResource headline4}" Content="File 1" Grid.Row="0" Grid.Column="1"/>
<TextBox Grid.Row="1" Style="{DynamicResource NormalTextBox}" Grid.Column="1"/>
<Button Grid.Column="2" Grid.Row="1" Style="{DynamicResource CommonButton}" Height="30" Width="30" VerticalAlignment="Top"/>
<Label Style="{DynamicResource headline5}" Grid.Row="1" Grid.Column="3"/>
<Label Style="{DynamicResource headline4}" Content="File 2" Grid.Row="2" Grid.Column="1"/>
<TextBox Grid.Row="3" Style="{DynamicResource NormalTextBox}" Grid.Column="1"/>
<Button Grid.Column="2" Grid.Row="3" Style="{DynamicResource CommonButton}" Height="30" Width="30" VerticalAlignment="Top"/>
<Label Style="{DynamicResource headline5}" Grid.Row="3" Grid.Column="3"/>
<!-- Hash Button and Selection -->
<ComboBox Grid.Row="4" Grid.Column="1" HorizontalAlignment="Left" Width="200" Height="30">
<ComboBoxItem>
Please Choose Your Algorithm
</ComboBoxItem>
</ComboBox>
<Button Grid.Column="1" Grid.Row="4" Style="{DynamicResource ActionBtn}" Content="Button" HorizontalAlignment="Right"/>
<!-- End-->
</Grid>
<!-- Content End-->
</Grid>
I cannot explain myself why the "blue bar" is not attached to the bottom. Despite the fact, that the window is so big.
I think you want to change this:
<Grid x:Name="WindowRoot" Margin="0" VerticalAlignment="Top" Background="Blue" MouseDown="Window_MouseDown">
to this:
<Grid x:Name="WindowRoot" Margin="0" VerticalAlignment="Stretch" Background="Blue" MouseDown="Window_MouseDown">

Adding controls to Contextmenu

I have a context menu that I would like to add a few controls too. In the example below I'm adding a TextBox,CheckBox and a Slider.
<ContextMenu>
<MenuItem Header="Cut"
Command="Cut" />
<MenuItem Header="Copy"
Command="Copy" />
<MenuItem Header="Paste"
Command="Paste" />
<Separator />
<Border Background="#999"
BorderThickness="1"
BorderBrush="Black"
Padding="5">
<Grid Width="300">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto" />
<ColumnDefinition Width="8" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="auto" />
<RowDefinition Height="auto" />
<RowDefinition Height="auto" />
</Grid.RowDefinitions>
<Label Content="PropA"
Grid.Column="0"
Grid.Row="0" />
<Label Content="PropB"
Grid.Column="0"
Grid.Row="1" />
<Label Content="PropC"
Grid.Column="0"
Grid.Row="2" />
<TextBox Text="-10"
Grid.Column="2"
Grid.Row="0" />
<CheckBox Grid.Column="2"
Grid.Row="1" />
<Slider Grid.Column="2"
Grid.Row="2" />
</Grid>
</Border>
</ContextMenu>
Which results in :
Is there anyway to get this to look better though?
Can I disable the Selectable blue border (shown in red) around the MenuItem ?
Can I stretch the controls to fit the Menu?
Your Border is wrapped in MenuItem. What you could do is use MenuItem and move Border to be its template
<ContextMenu>
<MenuItem Header="Cut" Command="Cut" />
<MenuItem Header="Copy" Command="Copy" />
<MenuItem Header="Paste" Command="Paste" />
<Separator />
<MenuItem>
<MenuItem.Template>
<ControlTemplate TargetType="{x:Type MenuItem}">
<Border Background="#999" BorderThickness="1" BorderBrush="Black" Padding="5">
<Grid Width="300">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto" />
<ColumnDefinition Width="8" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="auto" />
<RowDefinition Height="auto" />
<RowDefinition Height="auto" />
</Grid.RowDefinitions>
<Label Content="PropA" Grid.Column="0" Grid.Row="0" />
<Label Content="PropB" Grid.Column="0" Grid.Row="1" />
<Label Content="PropC" Grid.Column="0" Grid.Row="2" />
<TextBox Text="-10" Grid.Column="2" Grid.Row="0" />
<CheckBox Grid.Column="2" Grid.Row="1" />
<Slider Grid.Column="2" Grid.Row="2" />
</Grid>
</Border>
</ControlTemplate>
</MenuItem.Template>
</MenuItem>
</ContextMenu>

CustomerControl ZoomableScrollViewer

I try to create a customer control that is capable of zoom and some other features.
I think scroll viewer is the right base class. So i created a UserControl in the first atempt that derives from scrollviewer. But a UserControl can not contain named Content. Basically my control should behave like a any customer control.
So i read that i should implement the zoom behavior in a lookless customer control instead of a usercontrol.
Now I am curios how to get the control template from my first user control atempt into my customer control template:
<ScrollViewer.Template>
<ControlTemplate TargetType="{x:Type local:ZoomViewer}">
<Grid VerticalAlignment="Stretch" HorizontalAlignment="Stretch" >
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<ContentControl Grid.Column="0" ManipulationStarting="ContentControl_ManipulationStarting" ManipulationDelta="ContentControl_ManipulationDelta"
IsManipulationEnabled="true">
<ContentControl.LayoutTransform>
<ScaleTransform x:Name="PART_ScaleTransform"/>
</ContentControl.LayoutTransform>
<ScrollContentPresenter x:Name="PART_ScrollContentPresenter" Loaded="ScrollContentPresenter_Loaded"/>
</ContentControl>
<ScrollBar Name="PART_VerticalScrollBar" Value="{TemplateBinding VerticalOffset}" Maximum="{TemplateBinding ScrollableHeight}"
Grid.Row="0" Grid.Column="1"
ViewportSize="{TemplateBinding ViewportHeight}" Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}" />
<ScrollBar Name="PART_HorizontalScrollBar" Orientation="Horizontal" Grid.Row="1" Grid.Column="0"
Value="{TemplateBinding HorizontalOffset}"
Maximum="{TemplateBinding ScrollableWidth}" ViewportSize="{TemplateBinding ViewportWidth}" Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}" />
<Slider Grid.ColumnSpan="2" Grid.Column="0" Grid.Row="2" HorizontalAlignment="Left" Width="300" Minimum="0" Maximum="100" Value="0"
x:Name="PART_Slider" ValueChanged="Slider_ValueChanged"/>
</Grid>
</ControlTemplate>
</ScrollViewer.Template>
How do i add simple zoom behavior to a scroll viewer without xaml.
Maybe my atempt is totally wrong but i can't figure it out.
It's a bit difficult understanding your question but I think you're trying to do something like this:
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="100*" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<ScrollViewer HorizontalAlignment="Stretch" VerticalAlignment="Stretch" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" >
<Grid Width="200" Height="200" Background="AliceBlue">
<Grid.LayoutTransform>
<ScaleTransform ScaleX="{Binding ElementName=scaleControl, Path=Value}" ScaleY="{Binding ElementName=scaleControl, Path=Value}" />
</Grid.LayoutTransform>
<Button Width="64" Height="48">Hello</Button>
</Grid>
</ScrollViewer>
<Separator Grid.Row="1" Margin="5" />
<ScrollBar Name="scaleControl" Grid.Row="2" Minimum="1" Maximum="10" Orientation="Horizontal" />
</Grid>

WPF window shows blank

Excel AddIn, c#, .net 4.0, windows 7, ribbon
my addin has a ribbon tab, several ribbon buttons,
when one ribbon is clicked, the addin will send several web service calls and a window will pop up providing data in tab, treeview, gridview etc.
data in treeview, gridview are populated from web service calls.
All worked for a particular end user until yesterday
When he clicked button, the window seems showing up, but it is kind of behind Excel and could not be focused. Also it is blank with no tab, treeview, gridview, etc.
I verified all web service calls return properly.
The user has windows 7, Excel 2010 (32 bit).
I have no idea what could cause this. Please help.
this is my WPF window. thanks
<Window x:Class="MIMICWPFLib.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:sharedC="clr-namespace:MIMICShared.Converter;assembly=MstarCommodityShared"
xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core"
xmlns:dxt="clr-namespace:DevExpress.Xpf.Utils.Themes;assembly=DevExpress.Xpf.Core.v11.2"
xmlns:Controls="clr-namespace:MIMICWPFLib.Controls"
Title="{Binding Title}"
Height="600" Width="850" Top="223" Left="164" ResizeMode="CanResize" Closing="WindowClosing"
WindowStyle="ToolWindow">
<Window.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="MainWindowResources.xaml" />
<ResourceDictionary Source="Controls/BizzySpinner.xaml" />
</ResourceDictionary.MergedDictionaries>
<sharedC:BooleanToHiddenVisibility x:Key="boolToVis"/>
<sharedC:NegativeBooleanToHiddenVisibiltyConverter x:Key="negativeBoolToVis" />
<DataTemplate x:Key="{dxt:DXTabControlThemeKey ResourceKey=BackgroundTemplate, ThemeName=Office2007Silver}">
<Border BorderBrush="#FF828790" BorderThickness="1" Background="#E5E3E3"/>
</DataTemplate>
<DataTemplate x:Key="{dxt:DXTabControlThemeKey ResourceKey=BackgroundTemplate}">
<Border BorderBrush="#FF828790" BorderThickness="1" Background="White"/>
</DataTemplate>
<ControlTemplate x:Key="{dxt:DXTabControlThemeKey ResourceKey=TopLayoutTemplate}" TargetType="{x:Type dx:DXTabControl}">
<Grid>
<KeyboardNavigation.TabNavigation>Local</KeyboardNavigation.TabNavigation>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid Grid.Row="0" Margin="0,2,0,0" x:Name="tabHeadersPanel">
<KeyboardNavigation.TabIndex>1</KeyboardNavigation.TabIndex>
<KeyboardNavigation.DirectionalNavigation>Cycle</KeyboardNavigation.DirectionalNavigation>
<KeyboardNavigation.TabNavigation>Once</KeyboardNavigation.TabNavigation>
<Panel.ZIndex>1</Panel.ZIndex>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<dx:ClippedContainer Grid.Column="0" UseLayoutRounding="{TemplateBinding UseLayoutRounding}"
Style="{DynamicResource {dxt:DXTabControlInternalThemeKey ResourceKey=ClippedContainerTopLayoutStyle}}">
<dx:TabPanelContainer x:Name="panelContainer" Style="{DynamicResource {dxt:DXTabControlInternalThemeKey ResourceKey=PanelContainerTopLayoutStyle}}">
<dx:TabPanelContainer.Resources>
<Storyboard x:Key="ScrollStoryboard">
<DoubleAnimation Storyboard.TargetName="ItemsPanelTranslate"
Storyboard.TargetProperty="X" Duration="0:0:0.4" To="0">
<DoubleAnimation.EasingFunction>
<ExponentialEase EasingMode="EaseOut" Exponent="0" />
</DoubleAnimation.EasingFunction>
</DoubleAnimation>
</Storyboard>
</dx:TabPanelContainer.Resources>
<ItemsPresenter>
<ItemsPresenter.RenderTransform>
<TranslateTransform x:Name="ItemsPanelTranslate" />
</ItemsPresenter.RenderTransform>
</ItemsPresenter>
</dx:TabPanelContainer>
</dx:ClippedContainer>
<dx:TabControlScrollButton x:Name="PrevButton" Grid.Column="1" Style="{DynamicResource {dxt:DXTabControlThemeKey ResourceKey=PrevButtonStyle}}"
Margin="{DynamicResource {dxt:DXTabControlInternalThemeKey ResourceKey=ComponentsSpaceForHorizontalLayouts}}" />
<dx:TabControlScrollButton x:Name="NextButton" Grid.Column="2" Style="{DynamicResource {dxt:DXTabControlThemeKey ResourceKey=NextButtonStyle}}"
Margin="{DynamicResource {dxt:DXTabControlInternalThemeKey ResourceKey=ComponentsSpaceForHorizontalLayouts}}" />
<!--<dx:HeaderMenu Grid.Column="3" x:Name="HeaderMenu" IsTabStop="False" Style="{DynamicResource {dxt:DXTabControlThemeKey ResourceKey=HeaderMenuStyle}}"
Margin="{DynamicResource {dxt:DXTabControlInternalThemeKey ResourceKey=ComponentsSpaceForHorizontalLayouts}}" />-->
<Controls:HeaderMenuForDXTabControl Grid.Column="3"
x:Name="HeaderMenu"
IsTabStop="False"
Style="{DynamicResource {dxt:DXTabControlThemeKey ResourceKey=HeaderMenuStyle}}"
Margin="{DynamicResource {dxt:DXTabControlInternalThemeKey ResourceKey=ComponentsSpaceForHorizontalLayouts}}" />
</Grid>
<Grid Grid.Row="1">
<dx:DXContentPresenter ContentTemplate="{DynamicResource {dxt:DXTabControlThemeKey ResourceKey=BackgroundTemplate}}" IsTabStop="False">
</dx:DXContentPresenter>
<Grid Margin="1">
<dx:DXContentPresenter x:Name="contentPresenter" Margin="{TemplateBinding Padding}" UseLayoutRounding="{TemplateBinding UseLayoutRounding}"
Content="{TemplateBinding SelectedItemContent}" ContentTemplate="{TemplateBinding SelectedItemContentTemplate}">
<KeyboardNavigation.TabNavigation>Local</KeyboardNavigation.TabNavigation>
<KeyboardNavigation.DirectionalNavigation>Contained</KeyboardNavigation.DirectionalNavigation>
<KeyboardNavigation.TabIndex>2</KeyboardNavigation.TabIndex>
</dx:DXContentPresenter>
<dx:TabControlFastRenderPanel x:Name="fastRenderPanel" Margin="{TemplateBinding Padding}" UseLayoutRounding="{TemplateBinding UseLayoutRounding}" Visibility="Collapsed">
<KeyboardNavigation.TabNavigation>Local</KeyboardNavigation.TabNavigation>
<KeyboardNavigation.DirectionalNavigation>Contained</KeyboardNavigation.DirectionalNavigation>
<KeyboardNavigation.TabIndex>2</KeyboardNavigation.TabIndex>
</dx:TabControlFastRenderPanel>
</Grid>
</Grid>
</Grid>
</ControlTemplate>
</ResourceDictionary>
</Window.Resources>
<Grid>
<Grid Visibility="{Binding ShowProgress, Converter={StaticResource negativeBoolToVis}}">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" ></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
<Grid Grid.Row="0">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" MinHeight="65"></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="Auto" MinWidth="2"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Image Grid.Row ="0" Height="37" Width="174" Margin="11,6,0,0"
Name="image1" Stretch="Fill" VerticalAlignment="Top"
HorizontalAlignment="Left"
Source="/MstarCommodityWPFLib;component/Resources/MorningstarLogo_Red.gif" />
<Border Grid.ColumnSpan="1" Grid.Row="0" HorizontalAlignment="Right" Margin="0,10,0,0"
Height="50" Width="400" Background="white" BorderThickness="1" BorderBrush="White" >
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="23"/>
<RowDefinition Height="4"/>
<RowDefinition Height="23"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<ContentControl Content="{Binding Path=SearchBox}" Margin="0 0 5 0" />
<TextBlock Grid.Row="0" Grid.Column="1">
<Hyperlink Click="ShowSettings" TextDecorations="None">
<Image Source="{Binding ConfigImageFilePath}" ></Image>
</Hyperlink>
</TextBlock>
<TextBlock Grid.Row="2" Grid.Column="1">
<Hyperlink Click="HelpHyperlinkClick">
<Image Source="{Binding HelpIconFilePath}"></Image>
</Hyperlink>
</TextBlock>
</Grid>
</Border>
</Grid>
<Grid Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="Auto"></ColumnDefinition>
<ColumnDefinition Name="columnWidth" MaxWidth="350"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Grid x:Name="horizontalGrid">
<Grid.RowDefinitions>
<RowDefinition Height="*" MinHeight="125"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Name="rowHeight" MinHeight="150"></RowDefinition>
</Grid.RowDefinitions>
<dx:DXTabControl Grid.Row="0"
Margin="10 0 5 5"
Name="MainTabRegion"
SelectedIndex="{Binding Tabs.SelectedIndex}"
ItemsSource="{Binding Tabs.TabItems}"
DestroyContentOnTabSwitching="False" BorderThickness="5"
OverridesDefaultStyle="True">
<dx:DXTabControl.View>
<dx:TabControlScrollView
ShowHeaderMenu="True"
AllowHideTabItems="True"
CloseHeaderMenuOnItemSelecting="True" ShowHiddenTabItemsInHeaderMenu="True" />
</dx:DXTabControl.View>
<dx:DXTabControl.ItemContainerStyle>
<Style TargetType="{x:Type dx:DXTabItem}">
<Setter Property="Visibility" Value="{Binding IsVisible, Mode=OneWay, Converter={StaticResource boolToVis}}"/>
</Style>
</dx:DXTabControl.ItemContainerStyle>
<dx:DXTabControl.ItemHeaderTemplate>
<DataTemplate>
<TextBlock Text="{Binding Path=Header}"
Visibility="{Binding IsVisible, Mode=OneWay, Converter={StaticResource boolToVis}}"
OverridesDefaultStyle="True" />
</DataTemplate>
</dx:DXTabControl.ItemHeaderTemplate>
</dx:DXTabControl>
<GridSplitter Grid.Row="1"
Margin="10 0 5 5"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
ShowsPreview="true"
ResizeDirection="Rows"
Height="5" />
<Border Grid.Row="2" Margin="10 0 5 5">
<ContentControl Content="{Binding Path=Basket}" />
</Border>
</Grid>
<GridSplitter Margin="0 20 0 0" Grid.Column="1"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
ShowsPreview="true"
ResizeDirection="Columns"
x:Name="verticalSplitter"
DragCompleted="OnDragCompleted"
Width="5" />
<Border Grid.RowSpan="3" Grid.Column="2" Margin="3 20 0 0">
<ContentControl Content="{Binding Path=ColumnDataPreview}" />
</Border>
</Grid>
</Grid>
<Grid Height="25" Width="300" Visibility="{Binding ShowProgress, Converter={StaticResource boolToVis}}">
<ProgressBar IsIndeterminate="True" Orientation="Horizontal" />
<Viewbox>
<TextBlock Text="Loading ..." Padding="50 0"/>
</Viewbox>
</Grid>
</Grid>
I know this is old -- but we stumbled on to this with a legacy Office add-in that we support -- where one user is apparently experiencing this same issue.
We did some digging, and stumbled across this similar SO post: Blank WPF child windows on Windows 10
It looks like there are two options:
Instruct the user to update/fix their bad video card drivers.
Put a hack into the code that will force the content to redraw at just the right instant (i.e. InvalidateVisual is not sufficient, see the linked question's answers for more information).

Categories

Resources