Menu subitem will not stay open on click wpf - wpf

I need the Menu sub menu to stay open on click, i am using data template for my menuitems, and itemssource is a list of custom object,i am also using control template for menuitem, the problem is when an item is clicked on , the menu closes,here is the code for menuitem:
<MenuItem HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Width="64" Height="{Binding ElementName=menu,Path=ActualHeight}"
HeaderTemplate="{DynamicResource wifiIcon}" HorizontalAlignment="Stretch" Name="wifiMenuItem"
StaysOpenOnClick="True" ItemTemplate="{StaticResource WifiNetworkDataTemplate}">
<Border BorderThickness="1" BorderBrush="Black"></Border>
</MenuItem>
the datatemplate code:
<DataTemplate x:Key="WifiNetworkDataTemplate" DataType="{x:Type model:WifiNetwork}">
<StackPanel Orientation="Vertical" HorizontalAlignment="Stretch" Margin="0,10,0,0" Background="Transparent" x:Name="wifiStack">
<Grid HorizontalAlignment="Stretch">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="150"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Viewbox Grid.Column="0" x:Name="check" Width="16" Height="16" Visibility="{Binding IsConnected, Converter={StaticResource BooleanToVisibilityConverter}}" >
<Canvas Width="24" Height="24">
<Path Data="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z" Fill="Blue" />
</Canvas>
</Viewbox>
<Viewbox Grid.Column="3" x:Name="wifiSignal" Width="16" Height="16" Margin="10,0,0,0" >
<Canvas xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" x:Name="icon_vm_wifi" Width="32" Height="32">
<Path Fill="White" Data="M16.030 10.038c-4.179 0-8.082 1.662-10.992 4.678-0.207 0.216-0.201 0.557 0.015 0.764 0.104 0.101 0.239 0.152 0.374 0.152 0.141 0 0.283-0.055 0.389-0.165 2.706-2.802 6.333-4.348 10.214-4.348 3.809 0 7.388 1.495 10.077 4.208 0.208 0.21 0.553 0.214 0.765 0.004 0.211-0.211 0.213-0.555 0.004-0.765-2.894-2.922-6.745-4.529-10.846-4.529z" />
<Path Fill="White" Data="M29.821 11.573c-3.796-3.409-8.695-5.287-13.791-5.287-5.127 0-10.047 1.897-13.852 5.343-0.222 0.201-0.239 0.543-0.038 0.765 0.108 0.117 0.253 0.178 0.401 0.178 0.129 0 0.26-0.046 0.363-0.139 3.604-3.265 8.266-5.064 13.125-5.064 4.829 0 9.471 1.779 13.068 5.010 0.222 0.202 0.564 0.184 0.763-0.041 0.201-0.222 0.182-0.563-0.040-0.764z" />
<Path Fill="White" Data="M16.030 13.425c-3.19 0-6.183 1.59-8.009 4.253-0.169 0.246-0.108 0.582 0.139 0.751 0.093 0.066 0.201 0.095 0.306 0.095 0.171 0 0.34-0.082 0.446-0.235 1.625-2.367 4.284-3.783 7.117-3.783 2.82 0 5.476 1.405 7.1 3.758 0.171 0.246 0.507 0.307 0.752 0.137 0.247-0.17 0.308-0.507 0.137-0.753-1.827-2.645-4.812-4.224-7.99-4.224z" />
<Path Fill="White" Data="M16.030 17.987c-2.129 0-3.862 1.734-3.862 3.863 0 2.129 1.732 3.864 3.862 3.864s3.864-1.734 3.864-3.864c0-2.128-1.734-3.863-3.864-3.863zM16.030 24.632c-1.534 0-2.78-1.248-2.78-2.782s1.246-2.781 2.78-2.781 2.782 1.247 2.782 2.781c0 1.534-1.248 2.782-2.782 2.782z" />
</Canvas>
</Viewbox>
<Viewbox Grid.Column="2" x:Name="passwordNeeded" Width="16" Height="16" Margin="10,0,0,0" Visibility="{Binding IsSecure, Converter={StaticResource BooleanToVisibilityConverter}}" >
<Canvas Width="24" Height="24">
<Path Data="M12,17A2,2 0 0,0 14,15C14,13.89 13.1,13 12,13A2,2 0 0,0 10,15A2,2 0 0,0 12,17M18,8A2,2 0 0,1 20,10V20A2,2 0 0,1 18,22H6A2,2 0 0,1 4,20V10C4,8.89 4.9,8 6,8H7V6A5,5 0 0,1 12,1A5,5 0 0,1 17,6V8H18M12,3A3,3 0 0,0 9,6V8H15V6A3,3 0 0,0 12,3Z" Fill="Black" />
</Canvas>
</Viewbox>
<TextBlock Grid.Column="1" TextAlignment="Left" x:Name="wifiName" Text="{Binding Name}" HorizontalAlignment="Left" ></TextBlock>
</Grid>
<TextBlock x:Name="invalidPasswordTextBlock" Visibility="Collapsed"/>
<PasswordBox x:Name="wifiPasswordBox" Visibility="{Binding PasswordBoxShown, Converter={StaticResource BooleanToVisibilityConverter}}" />
</StackPanel>
</DataTemplate>
code for menuitem's control template:
<!--Menu Item-->
<ControlTemplate x:Key="menuItem1" TargetType="{x:Type MenuItem}">
<Border x:Name="templateRoot" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" SnapsToDevicePixels="True">
<Grid>
<Border x:Name="GlyphPanel" Background="Transparent"/>
<ContentPresenter Content="{TemplateBinding Header}" Height="{TemplateBinding Height}" Width="{TemplateBinding Width}"
ContentTemplate="{TemplateBinding HeaderTemplate}" Margin="{TemplateBinding Padding}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
/>
<Popup x:Name="Popup"
Placement="Bottom"
IsOpen="{TemplateBinding IsSubmenuOpen}"
AllowsTransparency="True"
Focusable="True"
StaysOpen="{TemplateBinding StaysOpenOnClick}"
PopupAnimation="Fade">
<Border Padding="10" Background="White" Opacity="0.7">
<ItemsPresenter HorizontalAlignment="Center" />
</Border>
</Popup>
</Grid>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsKeyboardFocusWithin" Value="True">
<Setter TargetName="templateRoot" Property="Background" Value="White" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
<Style x:Key="{x:Type MenuItem}" TargetType="{x:Type MenuItem}">
<Setter Property="Template" Value="{StaticResource menuItem1}"/>
</Style>

solved it by using a another menuitem inside wifimenuitem and setting its StaysOpenOnClick="True" and used a listbox and set its itemtemplate and itemssource in code:
<MenuItem StaysOpenOnClick="True">
<MenuItem.Header>
<ListBox x:Name="myListbox" ItemTemplate="{StaticResource WifiNetworkDataTemplate}" Focusable="True"></ListBox>
</MenuItem.Header>
</MenuItem>

Related

How can i avoid a highlight blue rectangle on a ListViewItem when mouse is over?

I created the following wpf control called "InertListView" that it is a custom ListView:
<Plugins:InertListView ItemsSource="{Binding Path=Data.InputPorts}"
Grid.Column="0"
Background="Transparent"
BorderThickness="0"
BorderBrush="{x:Null}"
>
<ListView.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Path Name="LeftPort"
Fill="{Binding Color}"
go:Node.PortId="{Binding Type}"
Tag="Left"
go:Node.LinkableFrom="False"
go:Node.LinkableTo="True"
go:Node.ToSpot="MiddleLeft"
go:Node.LinkableMaximum="1"
Grid.Column="0"
VerticalAlignment="Center"
HorizontalAlignment="Left"
Cursor="Hand"
Width="10.968"
Height="14"
Stretch="Fill"
StrokeThickness="2"
StrokeMiterLimit="2.75"
Stroke="#FF535755"
Data="F1 M 16.9835,22.9609C 16.7301,23.2861 16.1852,23.5528 15.7721,23.5528L 12.7187,23.553C 12.3071,23.553 11.9687,23.2161 11.9687,22.803L 11.9687,12.3032C 11.9687,11.8901 12.3071,11.5532 12.7187,11.5532L 15.7721,11.553C 16.1852,11.553 16.7301,11.8196 16.9835,12.1447L 20.7466,16.961C 21,17.2862 21,17.8195 20.7466,18.1447L 16.9835,22.9609 Z "
/>
<TextBlock x:Name="LabelPortLabel"
TextAlignment="Left"
FontFamily="/Connect IO;component/Fonts/#Segoe UI"
Grid.Column="1"
VerticalAlignment="Center"
FontSize="13"
Width="Auto"
Height="Auto"
Canvas.Top="0"
Text="{Binding Label}"
Margin="5 0 0 0"
Cursor="Arrow"
/>
</Grid>
</DataTemplate>
</ListView.ItemTemplate>
</Plugins:InertListView>
Below i show how i define the "InertListView":
public class InertListView : ListView
{
protected override DependencyObject GetContainerForItemOverride()
{
return new InertListViewItem();
}
}
public class InertListViewItem : ListViewItem
{
protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e)
{
//base.OnMouseLeftButtonDown(e);
//e.Handled = false;
}
}
My problem is that when i move the mouse over one of the ListViewItems appears a highlight blue rectangle. How can i avoid this behaviour?
Thanks in advance!
Ricardo
You'd need to change the template of the control. Something like this:
<Plugins:InertListView>
......
......
<Plugins:InertListView.ItemContainerStyle>
<Style TargetType="{x:Type ListViewItem}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ListViewItem}">
<Border x:Name="Bd"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}">
<ContentPresenter Margin="{TemplateBinding Padding}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Plugins:InertListView.ItemContainerStyle>
</Plugins:InertListView>
Override the HighlightBrush like below:
<Plugins:InertListView ItemsSource="{Binding Path=Data.InputPorts}"
Grid.Column="0"
Background="Transparent"
BorderThickness="0"
BorderBrush="{x:Null}"
>
<Plugins:InertListView.Resources>
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}"
Color="Transparent"/>
</Plugins:InertListView.Resources>

wpf Why is this path being scaled weirdly?

Can someone tell me why the purple path is not to the same scale as the second path? They are set in the control template for togglebutton, shown below. In addition, you can see the result here:
http://picpaste.com/weird_path-nxRoeKjb.jpg
<Grid x:Name="ToggleButtonGrid"
Background="Navy"
>
<Path x:Name="ExpandPath"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Stretch="Fill"
Fill="Gray"
Stroke="Purple"
Data="M 0 0 L 12 0 L 12 12 L 0 12 Z" />
<Path
HorizontalAlignment="Center"
VerticalAlignment="Center"
Fill="Gray"
Stretch="Fill"
Stroke="Yellow"
Data="M 0 6 L 12 6 Z" />
</Grid>
which is then set in the controltemplate for the treeview. I don't see why it is being resized. Both of them are just contained in a grid. I would expect the grid to resize, but I am getting this
<ControlTemplate TargetType="{x:Type TreeViewItem}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition x:Name="TreeViewExpanderColumn" MinWidth="19"
Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition/>
</Grid.RowDefinitions>
<ToggleButton x:Name="Expander"
Style="{StaticResource ExpandCollapseToggleStyle}"
IsChecked="{Binding Path=IsExpanded,
RelativeSource={RelativeSource TemplatedParent}}"
ClickMode="Press"/>
<Border Name="Bd"
Grid.Column="1"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="0"
Padding="0">
<ContentPresenter x:Name="PART_Header"
ContentSource="Header"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"/>
</Border>
<ItemsPresenter
x:Name="ItemsHost"
Margin="-19,0,0,0"
Grid.Row="1"
Grid.Column="1"
Grid.ColumnSpan="2"/>
It was an issue with using a Path to draw a line and some scaling. Not sure what was going on, but using a Line instead fixed it.
<Path
HorizontalAlignment="Center"
VerticalAlignment="Center"
Stretch="Fill"
Fill="Gray"
Stroke="White"
Data="M 0 0 L 12 0 L 12 12 L 0 12 Z" />
<Line
HorizontalAlignment="Center"
VerticalAlignment="Center"
Fill="Gray"
X1="0"
Y1="0"
X2="12"
Y2="0"
Stroke="White"
/>
<Line x:Name="VerticalCrossBar"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Fill="Gray"
X1="0"
Y1="0"
X2="0"
Y2="12"
Stroke="White"
/>

how I put image on progress bar?

i put progress bar but its not look proper
<ProgressBar Height="30" Width="300" VerticalAlignment="Center" BorderThickness="0" HorizontalAlignment="Center" Foreground="#0A8098" BorderBrush="Transparent" Name="pbProcessing" >
<ProgressBar.Background>
<ImageBrush ImageSource="/ClientApplication;component/Images/ProgressBackground.png"/>
</ProgressBar.Background>
<ProgressBar.Clip>
<RectangleGeometry RadiusX="20.5" RadiusY="20.5" Rect="0,0,300,19"/>
</ProgressBar.Clip>
</ProgressBar>
but i shown
Any idea how to put image on progress bar perfrectly? Thanks.
Try this
<ProgressBar Value="30" Height="30" Width="300" VerticalAlignment="Center" BorderThickness="0" HorizontalAlignment="Center" Foreground="#0A8098" BorderBrush="Transparent" Name="pbProcessing" >
<ProgressBar.Template>
<ControlTemplate>
<Grid>
<Image Name="PART_Track" Source="bird1.jpg" Stretch="Fill"/>
<Rectangle Name="PART_Indicator"
Fill="BlanchedAlmond"
HorizontalAlignment="Left"/>
</Grid>
</ControlTemplate>
</ProgressBar.Template>
</ProgressBar>

Looking for some WPF layout advice

I am trying to model the layout that is displayed in this image.
If you take a look, it has a number of textBoxes/checkboxes/buttons, a couple of diagonal controls, and another separate control (in a red outline).
The bottom screenshot shows what I would like to happen when a checkbox is checked in that separate control.
Any tips on how to lay this out and handle those diagonal portions? I tried just rotating textBlocks with borders but then the borders remain as rectangular, not cut off as in the image. I also had some trouble with getting them to position properly. I would also need the width of those diagonal sections to be bound somehow to the checkbox/textBox portion of that separate control in the red border.
Is my only choice to rotate borderless textBlocks and draw the lines myself using Paths and for the width expanding, bind it to some property of my separate control?
Thanks for any advice.
This looked like a fun challenge. Give the following XAML a try. It will automatically adjust the size of the columns as the content expands. The key is placing some canvas elements in a grid to allow the lines of the borders to flow into the adjacent cells. This could certainly be cleaned up with some styles and will be a little fragile if you need to tweak the sizes, but I think it demonstrates the approach:
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="ButtonStyleTestApp.MainWindow"
x:Name="Window"
Title="MainWindow"
Width="640" Height="480">
<Grid x:Name="LayoutRoot" Background="#FF44494D" SnapsToDevicePixels="True">
<Grid.Resources>
<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
</Grid.Resources>
<Grid Background="#DDD">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition MinWidth="30" Width="Auto"/>
<ColumnDefinition MinWidth="30" Width="Auto"/>
<ColumnDefinition MinWidth="30" Width="Auto"/>
<ColumnDefinition MinWidth="30" Width="Auto"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="60"/>
<RowDefinition Height="30"/>
</Grid.RowDefinitions>
<Border BorderThickness="1 1 0 1" BorderBrush="#888" Grid.Column="0" Grid.Row="1">
<TextBox Margin="10 5" VerticalAlignment="Center"/>
</Border>
<Border BorderThickness="1 1 0 1" BorderBrush="#888" Grid.Column="1" Grid.Row="1">
<StackPanel Orientation="Horizontal" VerticalAlignment="Center">
<CheckBox x:Name="CheckBox1" Margin="5" VerticalAlignment="Center"></CheckBox>
<TextBox Visibility="{Binding IsChecked, ElementName=CheckBox1, Converter={StaticResource BooleanToVisibilityConverter}}" Width="100" Margin="5" VerticalAlignment="Center"/>
</StackPanel>
</Border>
<Border BorderThickness="1 1 0 1" BorderBrush="#888" Grid.Column="2" Grid.Row="1">
<StackPanel Orientation="Horizontal" VerticalAlignment="Center">
<CheckBox x:Name="CheckBox2" Margin="5" VerticalAlignment="Center"></CheckBox>
<TextBox Visibility="{Binding IsChecked, ElementName=CheckBox2, Converter={StaticResource BooleanToVisibilityConverter}}" Width="100" Margin="5" VerticalAlignment="Center"/>
</StackPanel>
</Border>
<Border BorderThickness="1 1 0 1" BorderBrush="#888" Grid.Column="3" Grid.Row="1">
<StackPanel Orientation="Horizontal" VerticalAlignment="Center">
<CheckBox x:Name="CheckBox3" Margin="5" VerticalAlignment="Center"></CheckBox>
<TextBox Visibility="{Binding IsChecked, ElementName=CheckBox3, Converter={StaticResource BooleanToVisibilityConverter}}" Width="100" Margin="5" VerticalAlignment="Center"/>
</StackPanel>
</Border>
<Border BorderThickness="1" BorderBrush="#888" Grid.Column="4" Grid.Row="1">
<Button Margin="3" FontSize="10" VerticalAlignment="Center" Width="40">Click</Button>
</Border>
<Canvas Grid.Column="1">
<Grid ClipToBounds="False" Canvas.Top="30">
<Border
BorderBrush="#888"
BorderThickness="0 1 0 0"
RenderTransformOrigin="0 0"
Height="20"
Width="100"
Margin="0 0 0 -80">
<Border.RenderTransform>
<TransformGroup>
<ScaleTransform/>
<SkewTransform/>
<RotateTransform Angle="-45"/>
<TranslateTransform/>
</TransformGroup>
</Border.RenderTransform>
<TextBlock VerticalAlignment="Center" TextAlignment="Left" Margin="21 1 1 1" FontSize="11">
Testing 1
</TextBlock>
</Border>
</Grid>
</Canvas>
<Canvas Grid.Column="2">
<Grid ClipToBounds="False" Canvas.Top="30">
<Border
BorderBrush="#666"
BorderThickness="0 1 0 0"
RenderTransformOrigin="0 0"
Height="20"
Width="100"
Margin="0 0 0 -80">
<Border.RenderTransform>
<TransformGroup>
<ScaleTransform/>
<SkewTransform/>
<RotateTransform Angle="-45"/>
<TranslateTransform/>
</TransformGroup>
</Border.RenderTransform>
<TextBlock VerticalAlignment="Center" TextAlignment="Left" Margin="21 1 1 1" FontSize="11">
Testing 2
</TextBlock>
</Border>
</Grid>
</Canvas>
<Canvas Grid.Column="3">
<Grid ClipToBounds="False" Canvas.Top="30">
<Border
BorderBrush="#666"
BorderThickness="0 1 0 0"
RenderTransformOrigin="0 0"
Height="20"
Width="100"
Margin="0 0 0 -80">
<Border.RenderTransform>
<TransformGroup>
<ScaleTransform/>
<SkewTransform/>
<RotateTransform Angle="-45"/>
<TranslateTransform/>
</TransformGroup>
</Border.RenderTransform>
<TextBlock VerticalAlignment="Center" TextAlignment="Left" Margin="21 1 1 1" FontSize="11">
Testing 3
</TextBlock>
</Border>
</Grid>
</Canvas>
<Canvas Grid.Column="4">
<Grid ClipToBounds="False" Canvas.Top="30">
<Border
BorderBrush="#666"
BorderThickness="0 1 0 0"
RenderTransformOrigin="0 0"
Height="20"
Width="100"
Margin="0 0 0 -80">
<Border.RenderTransform>
<TransformGroup>
<ScaleTransform/>
<SkewTransform/>
<RotateTransform Angle="-45"/>
<TranslateTransform/>
</TransformGroup>
</Border.RenderTransform>
</Border>
</Grid>
</Canvas>
</Grid>
</Grid>
</Window>
I hope it helps.
It's definitely doable with borders and textblocks but it's tedious.
you'd have to play with negative margins a lot.
You could work it out with images instead of borders but you still need the textblocks on an angle using rendertransform
I'd definitely approach it using a Grid with a lot of columns of width Auto, place the easy components first then the tricky ones and do the rotations + neg margins last.
HTH.
As far as handling the diagonal elements goes, try putting the TextBlock within a Border, and transforming the border with a RotateTransform and SkewTransform. This should get you started:
<Grid HorizontalAlignment="Left" Height="100" Margin="64,60.5,0,0" VerticalAlignment="Top" Width="100" Background="Blue">
<Border BorderBrush="Black" BorderThickness="1" Margin="20,25.5,20.5,41.5" RenderTransformOrigin="0.5,0.5">
<Border.RenderTransform>
<TransformGroup>
<ScaleTransform/>
<SkewTransform AngleY="20"/>
<RotateTransform Angle="90"/>
<TranslateTransform/>
</TransformGroup>
</Border.RenderTransform>
<TextBlock TextWrapping="Wrap" Text="TextBlock" RenderTransformOrigin="0.5,0.5">
<TextBlock.RenderTransform>
<TransformGroup>
<ScaleTransform/>
<SkewTransform/>
<RotateTransform Angle="180"/>
<TranslateTransform/>
</TransformGroup>
</TextBlock.RenderTransform>
</TextBlock>
</Border>
</Grid>

Templates and inheritance

I have a big problem.
I use additional controls for Wpf. One of them is Telerik RadWindow
This control is already templated.
Now I want to create custom Window with will inherit from RadWindow, and make custom template, eg. One base window will contains grid and two buttons, second base window will contain two grids (master - detail).
The problem is that templates do not support inheritance. Perhaps is another way to template only the content of Winodow?
My code, that doesn't work (empty window appears, so template doesn't apply)
<Style TargetType="{x:Type local:TBaseRjWindow}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type local:TBaseRjContent}">
<Border Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}">
<Grid Name="mGrid">
<Grid.ColumnDefinitions>
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition MaxHeight="40" MinHeight="30" />
<RowDefinition MaxHeight="40" MinHeight="30" />
<RowDefinition Height="Auto" />
<RowDefinition MaxHeight="40" MinHeight="30" />
</Grid.RowDefinitions>
<telerik:RadGridView Margin="10,10,10,10" Name="grid" Grid.Row="0" Grid.Column="0" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" ScrollMode="Deferred" AutoGenerateColumns="False" Width="Auto" >
</telerik:RadGridView>
<telerik:RadDataPager Grid.Row="1" Grid.Column="0"
x:Name="radDataPager"
PageSize="50"
AutoEllipsisMode="None"
DisplayMode="First, Previous, Next, Text"
Margin="10,0,10,0"/>
<StackPanel Grid.Row="1" Grid.Column="0" Margin="5 5 5 5" HorizontalAlignment="Left" Orientation="Horizontal" Height="20" Width="Auto" VerticalAlignment="Center" >
<telerik:RadButton x:Name="btAdd" Margin="5 0 5 0" Content="Dodaj" />
<telerik:RadButton x:Name="btEdit" Margin="5 0 5 0" Content="Edytuj" />
<telerik:RadButton x:Name="btDelete" Margin="5 0 5 0" Content="Usun" />
</StackPanel>
<StackPanel Name="addFields" Background="LightGray" Visibility="Collapsed" VerticalAlignment="Top" Grid.Row="2" Grid.Column="0" Width="Auto" Height="Auto" Orientation="Horizontal">
<GroupBox Header="Szczegoly" Margin="2 2 2 2" >
<Grid VerticalAlignment="Top" DataContext="{Binding SelectedItem, ElementName=grid}" Name="_gAddFields" Margin="0 0 0 0" Width="Auto" Height="Auto" >
</Grid>
</GroupBox>
</StackPanel>
<StackPanel Grid.Row="3" Grid.Column="0" Margin="5 5 5 5" HorizontalAlignment="Right" Orientation="Horizontal" Height="25" Width="Auto" VerticalAlignment="Center" >
<telerik:RadButton x:Name="btSave" IsDefault="True" Width="60" Margin="5 0 5 0" Content="Zapisz" />
<telerik:RadButton x:Name="btOK" IsDefault="True" Width="60" Margin="5 0 5 0" Content="Akceptuj" />
<telerik:RadButton x:Name="btCancel" IsCancel="True" Width="60" Margin="5 0 5 0" Content="Anuluj" />
</StackPanel>
</Grid>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
Please help
You could use the ContentTemplate for the Window. It is a DataTemplate that will be used to display the Content set on the Window.

Resources