Using the gong drag and drop framework, one gets a drag effect, which is a simple border around the possible droptarget.
However, in my case for some reason this border doesn't fit the actual element, as shown here:
I have already tried to change background colors of the different xaml elements of the drop target to find out if some elements are bigger (but hidden), but couldn't find any.
I guess the problem is due to the usage of viewboxes, which I use, since the size of these drop targets is dynamic and zoom-able.
Here is the xaml code of drop target:
<Border BorderThickness="{Binding PlatformBorderThickness}" dd:DragDrop.IsDropTarget="True" dd:DragDrop.DropHandler="{StaticResource CustomDropHandler}" >
<Border.BorderBrush>
<LinearGradientBrush StartPoint="0,0" EndPoint="1,0" >
<GradientStop Color="Black" Offset="0"/>
<GradientStop Color="Black" Offset="0.1"/>
<GradientStop Color="Transparent" Offset="0.1"/>
<GradientStop Color="Transparent" Offset="0.9"/>
<GradientStop Color="Black" Offset="0.9"/>
<GradientStop Color="Black" Offset="1"/>
</LinearGradientBrush>
</Border.BorderBrush>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="10*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="10*"/>
</Grid.RowDefinitions>
<Viewbox Grid.Column="0" Grid.ColumnSpan="1" Grid.Row="0" Grid.RowSpan="1" HorizontalAlignment="Left">
<TextBlock Text="{Binding Equipment.Name, FallbackValue='Please add a device!'}" FontWeight="Bold"/>
</Viewbox>
<Viewbox Grid.Column="1" Grid.ColumnSpan="1" Grid.Row="0" Grid.RowSpan="1" Stretch="Uniform" HorizontalAlignment="Right">
<Button Command="{Binding DeleteButtonClick}" Background="Transparent" BorderThickness="0"
Margin="0" Padding="0">
<Image Source="/Resources/Cancel.ico"/>
</Button>
</Viewbox>
<Viewbox Grid.Column="0" Grid.ColumnSpan="3" Grid.Row="1" Grid.RowSpan="1" HorizontalAlignment="Left" VerticalAlignment="Top" Stretch="Uniform" Margin="2">
<DataGrid Width="200" Height="135" HeadersVisibility="None" RowBackground="Transparent" BorderThickness="0"
ItemsSource="{Binding Equipment.Settings}" SelectionMode="Single" AutoGenerateColumns="False" GridLinesVisibility="Vertical" CanUserAddRows="False"
GotFocus="DataGrid_GotFocus" Name="DutInfoGrid" >
<DataGrid.Resources>
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="Transparent"/>
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightTextBrushKey}" Color="Black"/>
<SolidColorBrush x:Key="{x:Static SystemColors.ControlBrushKey}" Color="Transparent"/>
</DataGrid.Resources>
<DataGrid.Background>
<ImageBrush ImageSource="{Binding Equipment.ImagePath, FallbackValue={StaticResource AddItemImage}, TargetNullValue={StaticResource AddItemImage}}"
Stretch="Fill" Opacity="0.25"/>
</DataGrid.Background>
<DataGrid.Columns>
<DataGridTemplateColumn >
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Button Name="DutInfoGridRemoveButton" Background="Transparent" BorderThickness="0" Margin="0" Padding="0" Height="15"
Command="{Binding Path=DataContext.RemoveClick, RelativeSource= {RelativeSource FindAncestor, AncestorType={x:Type DataGrid}}}"
CommandParameter="{Binding}">
<Image Source="/Resources/Trash.ico"/>
</Button>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTextColumn Binding="{Binding Items[3].Value}"/>
<DataGridTextColumn Binding="{Binding Items[6].Value}" />
</DataGrid.Columns>
</DataGrid>
</Viewbox>
</Grid>
</Border>
Edit:
After some further testing I found out that if I remove the ViewBox element around the datagrid, the problem is gone. Any ideas, why the ViewBox causes this issue and how to solve it?
You should probably switch to the action file, then swap and use jQuery with the XML code which will refer to the drag and drop.
Related
These borders appear when they are clicked or hovered and don't go until the focus is lost.
There are borders on all four sides but since it is embedded in a shorter grid, the top and bottom ones are not visible.
How to remove these borders?
Please provide an example if possible.
XAML:
<Border x:Name="SearchBorder" BorderThickness="1" HorizontalAlignment="Left" Height="40" Margin="672,34,0,0" VerticalAlignment="Top" Width="355" Background="#3F000000">
<Border.BorderBrush>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#4C000000" Offset="0"/>
<GradientStop Color="#3FFFFFFF" Offset="1"/>
</LinearGradientBrush>
</Border.BorderBrush>
<Grid>
<TextBox x:Name="SearchBox" HorizontalAlignment="Left" Height="40" Width="296" Margin="10,0,0,0" TextWrapping="Wrap" VerticalAlignment="Center" SelectionBrush="Black" Background="#00000000" Foreground="#FF5B5B5B" FontSize="25" FontFamily="Segoe UI Light" BorderBrush="#00000000" CaretBrush="#FF6C6C6C"/>
<TextBlock HorizontalAlignment="Left" Height="23" Margin="320,0,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Center" Width="21" FontFamily="FontAwesome" FontSize="25" Foreground="#FF919191"/>
<Rectangle HorizontalAlignment="Left" Margin="311,-2,0,0" Width="1">
<Rectangle.Stroke>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#3F404040" Offset="0"/>
<GradientStop Color="#3F686868" Offset="1"/>
<GradientStop Color="#59DADADA" Offset="0.502"/>
</LinearGradientBrush>
</Rectangle.Stroke>
</Rectangle>
</Grid>
</Border>
Try BorderThickness="0"
<TextBox x:Name="SearchBox" BorderThickness="0" HorizontalAlignment="Left" Height="40" Width="296" Margin="10,0,0,0" TextWrapping="Wrap" VerticalAlignment="Center" SelectionBrush="Black" Background="#00000000" Foreground="#FF5B5B5B" FontSize="25" FontFamily="Segoe UI Light" BorderBrush="#00000000" CaretBrush="#FF6C6C6C"/>
you can remove the border by just setting the BorderBrush property to Transparent.
Normal View: Set the BorderBrush property to "Transparent"
<Button Name="BtnTest"
Content="Test"
BorderBrush="Transparent"
Height="20"
Width="75"/>
Hovering View: While you are hovering the control with mouse, Include these Control Template for Button or any control like Textbox or Textblock etc.. under the Window.Resources Tag
<Window.Resources>
<Style TargetType="Button">
<!--Default Values-->
<Setter Property="BorderBrush"
Value="Transparent"/>
<!--Transparent Highlight-->
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border Background="{TemplateBinding Background}">
<ContentPresenter HorizontalAlignment="Center"
VerticalAlignment="Center"/>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Window.Resources>
I have created a custom control that utilizes pre-existing WPF controls. Inside the control I made some borders that visually separates the individual elements.
Here's the XAML code for the UserControl: TimeEntry:
<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"
mc:Ignorable="d"
x:Class="ClockWatcher.TimeEntry"
x:Name="UserControl"
d:DesignWidth="365" d:DesignHeight="40" VerticalAlignment="Top" HorizontalAlignment="Left">
<UserControl.Resources>
<Thickness x:Key="borderDim">0,0,1,0</Thickness>
<Thickness x:Key="labelPadding">2,0</Thickness>
<Color x:Key="borderColor">#FF151E3E</Color>
<Color x:Key="buttonColorBackground">#FFB3D6E6</Color>
</UserControl.Resources>
<Grid x:Name="LayoutRoot" HorizontalAlignment="Left" VerticalAlignment="Top">
<Border x:Name="mainBorder" BorderThickness="3" CornerRadius="1" Padding="1" Background="#FF9DB6BF" HorizontalAlignment="Left" VerticalAlignment="Top">
<Border.BorderBrush>
<SolidColorBrush Color="{DynamicResource borderColor}"/>
</Border.BorderBrush>
<Grid x:Name="borderGrid">
<StackPanel x:Name="mainStack" Orientation="Horizontal" HorizontalAlignment="Left" VerticalAlignment="Top">
<Border x:Name="timeInBorder" HorizontalAlignment="Center" VerticalAlignment="Center" BorderThickness="{DynamicResource borderDim}" Padding="{DynamicResource labelPadding}">
<Border.BorderBrush>
<SolidColorBrush Color="{DynamicResource borderColor}"/>
</Border.BorderBrush>
<StackPanel x:Name="timeInStack" Orientation="Vertical" Height="31.92" Width="50.46">
<Label x:Name="timeInLabel" Content="Time In" VerticalAlignment="Top" Padding="{DynamicResource labelPadding}" BorderThickness="0,0,0,1">
<Label.BorderBrush>
<SolidColorBrush Color="{DynamicResource borderColor}"/>
</Label.BorderBrush>
</Label>
<TextBlock x:Name="timeInBlock" HorizontalAlignment="Left" TextWrapping="Wrap" Text="{Binding timeIn.TimeOfDay, ElementName=UserControl}" VerticalAlignment="Top"/>
</StackPanel>
</Border>
<Border x:Name="timeOutBorder" HorizontalAlignment="Center" VerticalAlignment="Center" BorderThickness="{DynamicResource borderDim}" Padding="{DynamicResource labelPadding}">
<Border.BorderBrush>
<SolidColorBrush Color="{DynamicResource borderColor}"/>
</Border.BorderBrush>
<StackPanel x:Name="timeOutStack" Orientation="Vertical" Height="31.92" Width="54.46">
<Label x:Name="timeOutLabel" Content="Time Out" HorizontalAlignment="Left" VerticalAlignment="Top" Padding="{DynamicResource labelPadding}" BorderThickness="0,0,0,1">
<Label.BorderBrush>
<SolidColorBrush Color="{DynamicResource borderColor}"/>
</Label.BorderBrush>
</Label>
<TextBlock x:Name="timeOutBlock" HorizontalAlignment="Left" TextWrapping="Wrap" Text="{Binding timeOut.TimeOfDay, ElementName=UserControl}" VerticalAlignment="Top" Padding="{DynamicResource labelPadding}"/>
</StackPanel>
</Border>
<Border x:Name="timeSpentBorder" HorizontalAlignment="Center" VerticalAlignment="Center" BorderThickness="{DynamicResource borderDim}" Padding="{DynamicResource labelPadding}">
<Border.BorderBrush>
<SolidColorBrush Color="{DynamicResource borderColor}"/>
</Border.BorderBrush>
<StackPanel x:Name="timeSpentStack" Orientation="Vertical" Height="31.92" Width="63.653">
<Label x:Name="timeSpentLabel" Content="Time Spent" HorizontalAlignment="Left" VerticalAlignment="Top" Padding="{DynamicResource labelPadding}" BorderThickness="0,0,0,1">
<Label.BorderBrush>
<SolidColorBrush Color="{DynamicResource borderColor}"/>
</Label.BorderBrush>
</Label>
<TextBlock x:Name="timeSpentBlock" HorizontalAlignment="Left" TextWrapping="Wrap" Text="{Binding timeSpent,ElementName=UserControl}" VerticalAlignment="Top" Padding="{DynamicResource labelPadding}"/>
</StackPanel>
</Border>
<Button x:Name="alarmButton" Content="Alarm" HorizontalAlignment="Center" BorderThickness="0,0,1,0">
<Button.Background>
<SolidColorBrush Color="{DynamicResource buttonColorBackground}"/>
</Button.Background>
<Button.BorderBrush>
<SolidColorBrush Color="{DynamicResource borderColor}"/>
</Button.BorderBrush>
</Button>
<StackPanel x:Name="commentStack1" Orientation="Horizontal">
<TextBox x:Name="commentBox" HorizontalAlignment="Left" TextWrapping="Wrap" Text="{Binding comment,ElementName=UserControl}" VerticalAlignment="Top" Padding="{DynamicResource labelPadding}" BorderThickness="0" SourceUpdated="commentBox_SourceUpdated">
<TextBox.BorderBrush>
<SolidColorBrush Color="{DynamicResource borderColor}"/>
</TextBox.BorderBrush>
</TextBox>
<Button x:Name="commentButton" VerticalAlignment="Top" Content="Ad" BorderThickness="1,0" Padding="{DynamicResource labelPadding}">
<Button.Background>
<SolidColorBrush Color="{DynamicResource buttonColorBackground}"/>
</Button.Background>
<Button.BorderBrush>
<SolidColorBrush Color="{DynamicResource borderColor}"/>
</Button.BorderBrush>
</Button>
</StackPanel>
<Button x:Name="deleteButton" Content="X" Padding="{DynamicResource labelPadding}" HorizontalAlignment="Left" VerticalAlignment="Top" BorderBrush="{x:Null}" BorderThickness="{DynamicResource borderDim}">
<Button.Background>
<SolidColorBrush Color="{DynamicResource buttonColorBackground}"/>
</Button.Background>
</Button>
</StackPanel>
</Grid>
</Border>
</Grid>
</UserControl>
In Blend, or the designer view in VS2013, the borders will appear just fine. However, when I place an instance of this control into a grid in the MainWindow, the borders won't appear.
All I do is this in MainWindow:
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:ClockWatcher" x:Class="ClockWatcher.MainWindow"
Title="MainWindow" Height="554" Width="949">
<Window.Resources>
<UserControl x:Key="timeEntry"/>
</Window.Resources>
<Grid x:Name="mainGrid">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="250*"/>
<ColumnDefinition Width="445*"/>
<ColumnDefinition Width="246*"/>
</Grid.ColumnDefinitions>
<Grid x:Name="leftGrid" Grid.Column="0">
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
</Grid>
<Grid x:Name="rightGrid" Grid.Column="2">
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
</Grid>
<ScrollViewer x:Name="timeEntryList" Grid.Column="1" HorizontalAlignment="Left">
<StackPanel x:Name="scrollStack" Orientation="Vertical" VerticalAlignment="Top" HorizontalAlignment="Left">
<local:TimeEntry/>
</StackPanel>
</ScrollViewer>
</Grid>
</Window>
Can someone help me find out what I did wrong here? I've been reading a book to find out about dependency objects and dependency properties, which I've also added the UserControl, but I'm not sure what's really wrong with it right now.
Declare all these resources in App.xaml and it will work,
<Application.Resources>
<Thickness x:Key="borderDim">0,0,1,0</Thickness>
<Thickness x:Key="labelPadding">2,0</Thickness>
<Color x:Key="borderColor">#FF151E3E</Color>
<Color x:Key="buttonColorBackground">#FFB3D6E6</Color>
</Application.Resources>
i have a datatemplate for a tabitem in a tab control.
The datatemplate doesn't cover all the Tabitem control, the beckground is a gray or white, control default color.
The Datatemplate of the TabItem:
<DataTemplate x:Key="ClosableTabItemTemplate">
<Border BorderThickness="1" BorderBrush="Transparent" CornerRadius="4">
<!--Border to make the tab item gap from the content-->
<Border x:Name="InsideBorder" BorderThickness="3" BorderBrush="#D6EAFF" CornerRadius="4">
<!--Border for the rounded corners-->
<!--TabItem Content Grid-->
<Grid x:Name="tabItemGrid" ShowGridLines="True" Margin="0" Background="#D6EAFF">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="25"/>
<!--Icon Column-->
<ColumnDefinition Width="1*"/>
<!--Title Column-->
<ColumnDefinition Width="20"/>
<!--Close Button Column-->
</Grid.ColumnDefinitions>
<!--Icon of tab Item-->
<Image Grid.Column="0" Grid.Row="1" Height="18" HorizontalAlignment="Left" Source="Images/tab1.jpg"/>
<!--Title of tab Item-->
<Label Name="TabText" Grid.Column="1" Grid.Row="1" Content="TabItem" Height="23" HorizontalAlignment="Left"
Margin="4,1,0,0" VerticalAlignment="Top" FontFamily="Courier" FontSize="12" />
<!--Close button of tab Item-->
<Button Style="{DynamicResource TabButton}"
Name="button_close" Content="x"
Command="{Binding Path=CloseCommand}"
Grid.Column="2" Grid.Row="1"
Height="20" Width="20"
Margin="0,0,0,2" VerticalAlignment="Center" HorizontalAlignment="Right"
FontFamily="Courier" FontStretch="Normal" FontWeight="Bold" FontSize="14"
Visibility="Visible" ToolTip="Close"
BorderBrush="Transparent" BorderThickness="0" Background="Transparent" Padding="0,0,0,0"
>
</Button>
</Grid>
</Border>
</Border>
<DataTemplate.Triggers>
<DataTrigger Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type TabItem}},Path=IsSelected}" Value="True">
<Setter TargetName="tabItemGrid" Property="Background" Value="#D6EAFF" />
</DataTrigger>
<DataTrigger Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type TabItem}},Path=IsSelected}" Value="False">
<!--<Trigger Property="IsSelected" Value="False">-->
<Setter TargetName="InsideBorder" Property="BorderBrush">
<Setter.Value>
<LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
<GradientStop Color="#FFCCCCD0" />
<GradientStop Color="#FF526593" Offset="1" />
</LinearGradientBrush>
</Setter.Value>
</Setter>
<Setter TargetName="tabItemGrid" Property="Background">
<Setter.Value>
<LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
<GradientStop Color="#FFCCCCD0" />
<GradientStop Color="#FF526593" Offset="1" />
</LinearGradientBrush>
</Setter.Value>
</Setter>
</DataTrigger>
<!--</Trigger>-->
</DataTemplate.Triggers>
</DataTemplate>
The Tabcontrol:
<TabControl Name="MainTabCtrl" Margin="0" Padding="0" BorderThickness="0" Background="Transparent"
IsSynchronizedWithCurrentItem="True"
ItemsSource="{Binding Path=TabViewModels}"
ItemTemplate="{StaticResource ClosableTabItemTemplate}">
when the Xaml code of the tabitem wasn't inside a DataTemplate it worked fine - the "Transparent" of the first border did the job and no gray/white background appeared. but when i moved the code inside a DataTemplate the gray background appeared.
How do i make the background of the tabitem transparent?
I added HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" to the tabcontrol, it only narrows the gray area a bit but it still exsits.
Try to set Padding for TabItems to zero.
I have the following xaml and I am trying to get to the Grid to make it invisible at some point in my code if the code reaches there. Being new to .net and silverlight and xaml I am not sure why my code behind doesn't find Grid Controlpanel
please see my xaml code here
<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:smf="clr-namespace:Microsoft.SilverlightMediaFramework.Core;assembly=Microsoft.SilverlightMediaFramework.Core" xmlns:smfm="clr-namespace:Microsoft.SilverlightMediaFramework.Core.Media;assembly=Microsoft.SilverlightMediaFramework.Core" xmlns:plugins3d="clr-namespace:Microsoft.SilverlightMediaFramework.Plugins.Primitives.S3D;assembly=Microsoft.SilverlightMediaFramework.Plugins" xmlns:Microsoft_SilverlightMediaFramework_Utilities_Offline="clr-namespace:Microsoft.SilverlightMediaFramework.Utilities.Offline;assembly=Microsoft.SilverlightMediaFramework.Utilities" xmlns:System="clr-namespace:System;assembly=mscorlib" xmlns:smf_util="http://schemas.microsoft.com/smf/2010/xaml/converters" xmlns:smf_accesscontrols="http://schemas.microsoft.com/smf/2010/xaml/accesscontrols" xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity" xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions" xmlns:ec="http://schemas.microsoft.com/expression/2010/controls"
x:Class="SPlayer.MainPage"
d:DesignHeight="300" d:DesignWidth="400" mc:Ignorable="d">
<UserControl.Resources>
................
................
<Style x:Key="SMFPlayerStyle1" TargetType="smf:SMFPlayer">
<Setter Property="Background" Value="Black"/>
<Setter Property="HorizontalAlignment" Value="Stretch"/>
<Setter Property="VerticalAlignment" Value="Stretch"/>
<Setter Property="Template">
.......
......
<Grid x:Name="ControlPanelGrid" Margin="8,-26,8,13" Grid.Row="1" Grid.RowSpan="4" Opacity="0">
<Rectangle x:Name="ControlPanel" Margin="2,3,3,5" Stroke="#FF474747" RadiusY="4" RadiusX="4" Opacity="0.9" StrokeThickness="0.5">
<Rectangle.Effect>
<DropShadowEffect Opacity="0.26" BlurRadius="7" Direction="319"/>
</Rectangle.Effect>
<Rectangle.Fill>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#FF191919" Offset="0.936"/>
<GradientStop Color="#FF454545" Offset="0.187"/>
<GradientStop Color="#FF191919"/>
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
<Grid x:Name="timelinecontrols" Grid.ColumnSpan="1" Margin="0,0,165,13" d:LayoutOverrides="GridBox" d:IsHidden="True">
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<smf:Timeline x:Name="TimelineElement" Cursor="Hand" Chapters="{TemplateBinding Chapters}" EndPosition="{TemplateBinding EndPosition}" Foreground="{x:Null}" HorizontalContentAlignment="Stretch" IsLive="{TemplateBinding IsMediaLive}" LivePosition="{TemplateBinding LivePosition}" Margin="80,0,170,-10" StartPosition="{TemplateBinding StartPosition}" TimelineMarkers="{TemplateBinding TimelineMarkers}" VerticalAlignment="Center" Style="{StaticResource TimelineStyle1}" />
<Border x:Name="TimeContainer" BorderThickness="1" Grid.Column="1" HorizontalAlignment="Left" Margin="0" Opacity="0">
<Grid Height="28" MaxHeight="28" MinWidth="60" MinHeight="28" UseLayoutRounding="True">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.25*"/>
<ColumnDefinition Width="0.367*"/>
<ColumnDefinition Width="0.383*"/>
</Grid.ColumnDefinitions>
<TextBlock x:Name="CurrentPositionElement" Foreground="#FFC1C1C1" FontSize="9" HorizontalAlignment="Left" Padding="8,0,0,0" TextAlignment="Center" Text="{Binding PlaybackPosition, Converter={StaticResource TimeSpanValueConverter}, RelativeSource={RelativeSource TemplatedParent}}" VerticalAlignment="Center"/>
<TextBlock x:Name="TimeSeparatorElement" Grid.Column="1" Foreground="#FFFDFAFA" FontSize="9" HorizontalAlignment="Center" Margin="3,0" Opacity="0.4" Text="|" VerticalAlignment="Center"/>
<TextBlock x:Name="CurrentDurationElement" Grid.Column="2" Foreground="#FFFDFDFD" FontSize="9" HorizontalAlignment="Left" Opacity="0.4" Padding="0,0,8,0" Text="{Binding EndPosition, Converter={StaticResource TimeSpanValueConverter}, RelativeSource={RelativeSource TemplatedParent}}" VerticalAlignment="Center"/>
</Grid>
</Grid>
</Border>
</Grid>
<Image x:Name="btnVloume" Margin="0,-1,383,5" Source="volume.png" Stretch="Fill" Height="49" d:LayoutOverrides="Width, GridBox" Width="53" HorizontalAlignment="Right" d:IsHidden="True"/>
<smf:VolumeControl x:Name="VolumeElement" VolumeLevel=".5" RenderTransformOrigin="0.5,0.5" Margin="0,-46.5,326.074,-50.5" UseLayoutRounding="False" d:LayoutRounding="Auto" HorizontalAlignment="Right" Width="36" Style="{StaticResource VolumeControlStyle1}" d:IsHidden="True" >
<smf:VolumeControl.RenderTransform>
<CompositeTransform Rotation="90.02"/>
</smf:VolumeControl.RenderTransform>
</smf:VolumeControl>
<ToggleButton x:Name="FullScreenToggleElement" BorderThickness="0" Cursor="Hand" HorizontalAlignment="Right" HorizontalContentAlignment="Stretch" Height="28" Margin="0,14,153,11" Padding="0" Style="{StaticResource FullScreenElementStyle}" VerticalContentAlignment="Stretch" Width="29" d:LayoutOverrides="HorizontalAlignment" Opacity="0"/>
<Image x:Name="_3D" HorizontalAlignment="Right" Margin="0,1,180,3" Source="3D.png" Stretch="Fill" Width="53" Height="49" Cursor="Hand" Opacity="0.8" MouseLeftButtonUp="_3D_MouseLeftButtonUp">
<i:Interaction.Triggers>
<i:EventTrigger EventName="MouseEnter">
<ei:ChangePropertyAction x:Name="_3d_100_Opacity" PropertyName="Opacity" Value="1"/>
</i:EventTrigger>
<i:EventTrigger EventName="MouseLeave">
<ei:ChangePropertyAction x:Name="_3d_80_Opacity" PropertyName="Opacity" Value="0.8"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</Image>
<Image x:Name="analytics" HorizontalAlignment="Left" Margin="980,3,0,-1" Source="analytics.png" Stretch="Fill" Width="53" Cursor="Hand" Opacity="0.7">
<i:Interaction.Triggers>
<i:EventTrigger EventName="MouseEnter">
<ei:ChangePropertyAction x:Name="analytics_MouseEnter" PropertyName="Opacity" Value="1"/>
</i:EventTrigger>
<i:EventTrigger EventName="MouseLeave">
<ei:ChangePropertyAction x:Name="analytics_MouseLeave" PropertyName="Opacity" Value="0.7"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</Image>
<Image x:Name="btn_fullscreen" HorizontalAlignment="Right" Margin="0,0,140,4" Source="full_screen.png" Stretch="Fill" Width="53" Height="49" Opacity="0.8" Cursor="Hand">
<i:Interaction.Triggers>
<i:EventTrigger EventName="MouseEnter">
<ei:ChangePropertyAction x:Name="btn_fullscreen_mouseOver" PropertyName="Opacity" Value="1"/>
</i:EventTrigger>
<i:EventTrigger EventName="MouseLeave">
<ei:ChangePropertyAction x:Name="btn_fullscreen_mouseOut" PropertyName="Opacity" Value="0.8"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</Image>
<smf:PlayElement x:Name="PlayElement" Content="PlayElement" PlayState="{TemplateBinding PlayState}" HorizontalAlignment="Left" Height="51" Margin="9,2,0,0" Style="{StaticResource PlayElementStyle1}" Width="53" Cursor="Hand" />
<Image Margin="0,4,5,8" Source="logo.png" Stretch="Fill" HorizontalAlignment="Right" Width="96"/>
</Grid>
<Grid x:Name="ControllerContainer" Height="40" Grid.Row="4" Visibility="{Binding IsControlStripVisible, Converter={StaticResource BoolToVisibilityConverter}, RelativeSource={RelativeSource TemplatedParent}}" Opacity="0">
<Grid.Background>
<LinearGradientBrush EndPoint="0.481481,1" StartPoint="0.481481,0.00636957">
<GradientStop Color="#FF78808B" Offset="0"/>
<GradientStop Color="#FF58606A" Offset="0.287958"/>
<GradientStop Color="#FF38424E" Offset="0.680628"/>
<GradientStop Color="#FF333D49" Offset="0.984293"/>
</LinearGradientBrush>
</Grid.Background>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Grid x:Name="playercontrols" Grid.ColumnSpan="1" Margin="19,0,16,0" Opacity="0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Button x:Name="ReplayElement" BorderThickness="0" HorizontalAlignment="Right" Height="28" Margin="0" Style="{StaticResource ReplayButtonStyle}" Width="36"/>
<Button x:Name="RewindElement" BorderThickness="0,1,0,0" Grid.Column="1" HorizontalAlignment="Right" Height="28" Margin="0" Style="{StaticResource RWButtonStyle}" Width="36">
<Button.BorderBrush>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#FFA3AEB9" Offset="0"/>
<GradientStop Color="#FF8399A9" Offset="0.375"/>
<GradientStop Color="#FF718597" Offset="0.375"/>
<GradientStop Color="#FF617584" Offset="1"/>
</LinearGradientBrush>
</Button.BorderBrush>
</Button>
<smf:PlayElement Cursor="Hand" Grid.Column="2" Margin="0" PlayState="{TemplateBinding PlayState}" Width="60"/>
<Button x:Name="FastForwardElement" BorderThickness="0" Grid.Column="3" HorizontalAlignment="Right" Height="28" Margin="0" Style="{StaticResource FFButtonStyle}" Width="36"/>
<ToggleButton x:Name="SlowMotionElement" Grid.Column="4" HorizontalAlignment="Right" Height="28" Margin="0" Style="{StaticResource SlowMotionButtonStyle}" ToolTipService.ToolTip="Slow Motion" Width="36"/>
</Grid>
<Grid x:Name="divider1" Grid.Column="1" HorizontalAlignment="Left" Width="2">
<Path Data="M245.16667,0 L245.16667,39.109009" HorizontalAlignment="Left" Stretch="Fill" UseLayoutRounding="False" Width="1">
<Path.Stroke>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="Black" Offset="0.509"/>
<GradientStop Color="#FF343E4A" Offset="1"/>
<GradientStop Color="#FF757D87" Offset="0"/>
</LinearGradientBrush>
</Path.Stroke>
</Path>
<Path Data="M245.16667,0 L245.16667,39.109009" HorizontalAlignment="Left" Margin="1,0,0,0" Stretch="Fill" UseLayoutRounding="False" Width="1">
<Path.Stroke>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#FFFDFEFF" Offset="0.509"/>
<GradientStop Color="#FF36404C" Offset="1"/>
<GradientStop Color="#FF757D87" Offset="0"/>
</LinearGradientBrush>
</Path.Stroke>
</Path>
</Grid>
<Grid x:Name="divider2" Grid.Column="3" HorizontalAlignment="Left" Width="2" Opacity="0">
<Path Data="M245.16667,0 L245.16667,39.109009" HorizontalAlignment="Left" Stretch="Fill" UseLayoutRounding="False" Width="1">
<Path.Stroke>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="Black" Offset="0.509"/>
<GradientStop Color="#FF343E4A" Offset="1"/>
<GradientStop Color="#FF757D87" Offset="0"/>
</LinearGradientBrush>
</Path.Stroke>
</Path>
<Path Data="M245.16667,0 L245.16667,39.109009" HorizontalAlignment="Left" Margin="1,0,0,0" Stretch="Fill" UseLayoutRounding="False" Width="1">
<Path.Stroke>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#FFFDFEFF" Offset="0.509"/>
<GradientStop Color="#FF343E4A" Offset="1"/>
<GradientStop Color="#FF757D87" Offset="0.009"/>
</LinearGradientBrush>
</Path.Stroke>
</Path>
</Grid>
<Grid x:Name="functioncontrols" Grid.ColumnSpan="1" Grid.Column="4" Margin="16,0" Opacity="0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<ToggleButton x:Name="CaptionToggleElement" Cursor="Hand" Content="CC" Grid.Column="0" HorizontalAlignment="Right" Height="28" Margin="0" Style="{StaticResource CaptionDisplayToggleButtonStyle}" ToolTipService.ToolTip="Closed Captions" Width="36" d:LayoutOverrides="GridBox"/>
<ToggleButton x:Name="GraphToggleElement" Cursor="Hand" Content="G" Grid.Column="1" Height="28" Style="{StaticResource PlayerGraphButtonStyle}" ToolTipService.ToolTip="Toggle Graph" Width="36"/>
<ComboBox x:Name="AudioStreamSelectionElement" BorderBrush="{StaticResource btnBaseGradient}" Background="Black" Cursor="Hand" Grid.ColumnSpan="1" Grid.Column="3" Foreground="Black" HorizontalAlignment="Right" Height="28" ItemsSource="{TemplateBinding AvailableAudioStreams}" Margin="0" Style="{StaticResource AudioStreamMenu}" SelectedItem="{TemplateBinding SelectedAudioStream}" Width="110">
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Foreground="{StaticResource iconGradient}" Text="{Binding Name}"/>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
</Grid>
<Grid x:Name="divider3" Grid.Column="5" HorizontalAlignment="Left" Height="40" Margin="0" Width="2" Opacity="0">
<Path Data="M245.16667,0 L245.16667,39.109009" HorizontalAlignment="Left" Stretch="Fill" UseLayoutRounding="False" Width="1">
<Path.Stroke>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="Black" Offset="0.509"/>
<GradientStop Color="#FF343E4A" Offset="1"/>
<GradientStop Color="#FF757D87" Offset="0"/>
</LinearGradientBrush>
</Path.Stroke>
</Path>
<Path Data="M245.16667,0 L245.16667,39.109009" HorizontalAlignment="Left" Margin="1,0,0,0" Stretch="Fill" UseLayoutRounding="False" Width="1">
<Path.Stroke>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#FFFDFEFF" Offset="0.509"/>
<GradientStop Color="#FF343E4A" Offset="1"/>
<GradientStop Color="#FF757D87" Offset="0"/>
</LinearGradientBrush>
</Path.Stroke>
</Path>
</Grid>
<smf:BitrateMonitor x:Name="BitrateMonitorElement" Grid.Column="6" HighDefinitionBitrate="{TemplateBinding HighDefinitionBitrate}" Height="40" Margin="5,0,7,0" MaximumPlaybackBitrate="{TemplateBinding MaximumPlaybackBitrate}" PlaybackBitrate="{TemplateBinding PlaybackBitrate}" Width="36" Opacity="0"/>
</Grid>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</UserControl.Resources>
<Grid x:Name="LayoutRoot" Background="White">
<smf:SMFPlayer x:Name="smfPlayer" Style="{StaticResource SMFPlayerStyle1}" PlaylistVisibility="Disabled"/>
</Grid>
</UserControl>
here is my code behind file
namespace SPlayer
{
public partial class MainPage : UserControl
{
.........
public MainPage(StartupEventArgs e)
{
......
as you can see my namespace is correct in xaml but I still cant access the grid <Grid x:Name="ControlPanelGrid" Margin="8,-26,8,13" Grid.Row="1" Grid.RowSpan="4" Opacity="0">
thanks
In your C# code you can use the FindChild<T> found in this SO question
It would look something like:
Grid controlPanelGrid = UIHelper.FindChild<Grid>(smfPlayer, "ControlPanelGrid");
For clarification: your Grid ControlPanelGrid is a child of SMFPlayerStyle1 in the resources of your UserControl?
<UserControl.Resources>
<Style x:Key="SMFPlayerStyle1" TargetType="smf:SMFPlayer">
[...]
<Grid x:Name="ControlPanelGrid" Margin="8,-26,8,13" Grid.Row="1" Grid.RowSpan="4" Opacity="0">
[...]
</Style>
</UserControl.Resources>
To access this element programatically, you need to dive down the object graph starting with SMFPlayerStyle1.... Depending on structure of the SMFPlayer object you may be able to access it through a property of this.
WPF Experts -
I am trying to add buttons below my custom listbox and also have the scroll bar go to the bottom of the control. Only the items should move and not the buttons. I was hoping for some guidance on the best way to achieve this. I was thinking the ItemsPanelTemplate needed to be modified but was not certain.
Thanks
My code is below
<!-- List Item Selected -->
<LinearGradientBrush x:Key="GotFocusStyle" EndPoint="0.5,1" StartPoint="0.5,0">
<LinearGradientBrush.GradientStops>
<GradientStop Color="Black" Offset="0.501"/>
<GradientStop Color="#FF091F34"/>
<GradientStop Color="#FF002F5C" Offset="0.5"/>
</LinearGradientBrush.GradientStops>
</LinearGradientBrush>
<!-- List Item Hover -->
<LinearGradientBrush x:Key="MouseOverFocusStyle" StartPoint="0,0" EndPoint="0,1">
<LinearGradientBrush.GradientStops>
<GradientStop Color="#FF013B73" Offset="0.501"/>
<GradientStop Color="#FF091F34"/>
<GradientStop Color="#FF014A8F" Offset="0.5"/>
<GradientStop Color="#FF003363" Offset="1"/>
</LinearGradientBrush.GradientStops>
</LinearGradientBrush>
<!-- List Item Selected -->
<LinearGradientBrush x:Key="LostFocusStyle" EndPoint="0.5,1" StartPoint="0.5,0">
<LinearGradientBrush.RelativeTransform>
<TransformGroup>
<ScaleTransform CenterX="0.5" CenterY="0.5"/>
<SkewTransform CenterX="0.5" CenterY="0.5"/>
<RotateTransform CenterX="0.5" CenterY="0.5"/>
<TranslateTransform/>
</TransformGroup>
</LinearGradientBrush.RelativeTransform>
<GradientStop Color="#FF091F34" Offset="1"/>
<GradientStop Color="#FF002F5C" Offset="0.4"/>
</LinearGradientBrush>
<!-- List Item Highlight -->
<SolidColorBrush x:Key="ListItemHighlight" Color="#FFE38E27" />
<!-- List Item UnHighlight -->
<SolidColorBrush x:Key="ListItemUnHighlight" Color="#FF6FB8FD" />
<Style TargetType="ListBoxItem">
<EventSetter Event="GotFocus" Handler="ListItem_GotFocus"></EventSetter>
<EventSetter Event="LostFocus" Handler="ListItem_LostFocus"></EventSetter>
</Style>
<DataTemplate x:Key="CustomListData" DataType="{x:Type ListBoxItem}">
<Border BorderBrush="Black" BorderThickness="1" Margin="-2,0,0,-1">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ListBoxItem}}, Path=ActualWidth}" />
</Grid.ColumnDefinitions>
<Label
VerticalContentAlignment="Center" BorderThickness="0" BorderBrush="Transparent"
Foreground="{StaticResource ListItemUnHighlight}"
FontSize="24"
Tag="{Binding .}"
Grid.Column="0"
MinHeight="55"
Cursor="Hand"
FontFamily="Arial"
FocusVisualStyle="{x:Null}"
KeyboardNavigation.TabNavigation="None"
Background="{StaticResource LostFocusStyle}"
MouseMove="ListItem_MouseOver"
>
<Label.ContextMenu>
<ContextMenu Name="editMenu">
<MenuItem Header="Edit"/>
</ContextMenu>
</Label.ContextMenu>
<TextBlock Text="{Binding .}" Margin="15,0,40,0" TextWrapping="Wrap"></TextBlock>
</Label>
<Image
Tag="{Binding .}"
Source="{Binding}"
Margin="260,0,0,0"
Grid.Column="1"
Stretch="None"
Width="16"
Height="22"
HorizontalAlignment="Center"
VerticalAlignment="Center"
/>
</Grid>
</Border>
</DataTemplate>
</Window.Resources>
<Window.DataContext>
<ObjectDataProvider ObjectType="{x:Type local:ImageLoader}" MethodName="LoadImages" />
</Window.DataContext>
<ListBox ItemsSource="{Binding}" Width="320" Background="#FF021422" BorderBrush="#FF1C4B79" >
<ListBox.Resources>
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}">Transparent</SolidColorBrush>
<Style TargetType="{x:Type ListBox}">
<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Disabled" />
<Setter Property="ItemTemplate" Value="{StaticResource CustomListData }" />
</Style>
</ListBox.Resources>
</ListBox>
Why don't you place the two controls (the list and the buttons panel) into a StackPanel?
<StackPanel HorizontalAlignment="Left" Margin="0,0,0,0" Width="240">
<ListBox Height="320"/>
<Button Content="buttons go here"/>
</StackPanel>
You obviously won't get the listbox's scrollbar to go to the bottom of the screen, but you could fix that by putting in a ScrollBar control.
Editing templates might yield what you want but you may simply run into a point where items at the bottom of the list could be hidden by the button panel. You could overcome this obviously by increasing the bottom padding of the last item in that list or a similar margin/padding hack.
However, I don't think sizing the scrollbar to the bottom is the best idea in terms of common sense in user interfaces as scrollbars should conventionally be placed on the side of only what is scrollable.
I know I'm joing the party rather late, but you should be able to accomplish this by applying a custom ScrollViewier control template to be used by the ListBox. I have not tested this, but it should work (or at least offer a starting point):
<ListBox ...>
<ListBox.Resources>
<Style TargetType="ScrollViewer">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ScrollViewer">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<!-- Items Go Here -->
<ScrollContentPresenter Grid.Column="0" />
<!-- Buttons Go Here -->
<Grid Grid.Column="0"
Grid.Row="1"
>
...
</Grid>
<!-- ScrollBar spans all three rows but should only affect the presenter -->
<ScrollBar x:Name="PART_VerticalScrollBar"
Grid.Column="1"
Grid.Row="0"
Grid.RowSpan="3"
Value="{TemplateBinding VerticalOffset}"
Maximum="{TemplateBinding ScrollableHeight}"
ViewportSize="{TemplateBinding ViewportHeight}"
Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}"
/>
<ScrollBar x:Name="PART_HorizontalScrollBar"
Grid.Column="0"
Grid.Row="1"
Orientation="Horizontal"
Value="{TemplateBinding HorizontalOffset}"
Maximum="{TemplateBinding ScrollableWidth}"
ViewportSize="{TemplateBinding ViewportWidth}"
Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}"
/>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ListBox.Resources>
</ListBox>