Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all 18858 articles
Browse latest View live

how to make the items in my custom listbox, tab stops

$
0
0

Hi All,

I have the following code, wich displays a listbox, that is dynamically populated in the code behind. So the amount of items may vary. I would like each entry in the listbox (each set of label + combobox || label + textbox), to become a tabstop. Currently only the first item is a tab stop, and then when I press tab again, the first text box or combo (that is WITHIN the list) becomes tab stop. 

Alternatively if this is not possible, I want the input mechanisms should become tab stops, such as the combo and the text....

Here is code behind:

<Window 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:Microsoft_Windows_Themes="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero"
    xmlns:cl="clr-namespace:CommunicationLayer"
    xmlns:System="clr-namespace:System;assembly=mscorlib" x:Class="CommunicationLayer.CustomListControl"
    Closing="Window_Closing" ResizeMode="CanResizeWithGrip" Topmost="True"
    AllowsTransparency="True" WindowStyle="None" Background="Transparent"
    SizeToContent="Height"    
    Left="{cl:SettingBinding Left}" Top="{cl:SettingBinding Top}"
    MinHeight="180" MinWidth="200"
    mc:Ignorable="d" x:Name="Annotation"  Title="{Binding DatabaseColumnName}"><Window.Resources><!-- DV Link Colours --><Color x:Key="InputBoxBorderColour">Black</Color><Color x:Key="DVLinkLightBlue">#7f23b7c2</Color><SolidColorBrush x:Key="DVLinkLightBlueBrush" Color="{DynamicResource DVLinkLightBlue}" /><Color x:Key="DVLinkBlue">#FF00C7D5</Color><SolidColorBrush  x:Key="DVLinkBlueBrush" Color="{DynamicResource DVLinkBlue}" /><Color x:Key="DVLinkBlueComboSelectionBG">#00C7D5</Color><SolidColorBrush  x:Key="DVLinkBlueComboSelectionBGBrush" Color="{DynamicResource DVLinkBlueComboSelectionBG}" /><Color x:Key="DVLinkBlueGradientStop">White</Color><Color x:Key="DVLinkBorderGray">Gray</Color><SolidColorBrush  x:Key="DVLinkBorderGrayBrush" Color="{DynamicResource DVLinkBorderGray}" /><Color x:Key="DisabledForegroundColor">Red</Color><Color x:Key="DVLinkDropdownBGColour">LightGray</Color><Color x:Key="BorderMediumColor">#FF888888</Color><Style x:Key="DVLinkListboxStyle"><!-- this overrides the colour that is displayed when a listbox item is selected (default windows blue theme) --><Style.Resources><ImageBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" /><!-- Background of selected item when not focussed --><SolidColorBrush x:Key="{x:Static SystemColors.ControlBrushKey}" Color="Transparent"/></Style.Resources></Style><ControlTemplate x:Key="ComboBoxToggleButtonCircle" 
                 TargetType="{x:Type ToggleButton}"><Grid  ><Grid.ColumnDefinitions><ColumnDefinition /><ColumnDefinition Width="20" /></Grid.ColumnDefinitions><Border x:Name="Border" Grid.ColumnSpan="2" CornerRadius="2" BorderThickness="0.5"   ><Border.BorderBrush><SolidColorBrush Color="DarkGray" /><!--This will change the colour of the combobox's textbox border (not the dropdown's border)--></Border.BorderBrush></Border><Border Grid.Column="0"
                        CornerRadius="0,0,0,0"
                        Margin="0"  ><!--Margin of 0.75 above neccessary to prevent the RHS colour from 'spilling' throug on the left --><Border.Background><SolidColorBrush Color="Transparent"/></Border.Background></Border><Grid Grid.Column="1"><Ellipse Grid.Column="1" Width="16" Height="16" Fill="{DynamicResource DVLinkBlueBrush}"  Stroke="DarkGray" HorizontalAlignment="Center"
                      VerticalAlignment="Center" Margin="0,0,2,0" /><Path x:Name="Arrow"
                      Grid.Column="1"
                      HorizontalAlignment="Center"
                      VerticalAlignment="Center"
                      Data="M 0 0 L 4 4 L 8 0 Z" Margin="0,0,2,0" ><Path.Fill><SolidColorBrush Color="{DynamicResource DVLinkBorderGray}"/></Path.Fill></Path></Grid></Grid></ControlTemplate><ControlTemplate x:Key="ComboBoxTextBox"
                 TargetType="{x:Type TextBox}"><Border x:Name="PART_ContentHost" Focusable="True" Background="{TemplateBinding Background}"  /></ControlTemplate><Style x:Key="{x:Type ComboBox}"
               TargetType="{x:Type ComboBox}"><Setter Property="Margin" Value="0,10,0,0"/><Setter Property="Width" Value="120"/><Setter Property="Height" Value="24"/><Setter Property="OverridesDefaultStyle" Value="true" /><Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto" /><Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto" /><Setter Property="ScrollViewer.CanContentScroll" Value="true" /><Setter Property="MinWidth" Value="120" /><Setter Property="MinHeight" Value="24" /><Setter Property="VerticalContentAlignment" Value="Center"/><Setter Property="Foreground" Value="Black"/><!-- * The currently selected text : displayed in the textbox part of combobox *--><Setter Property="Template"><Setter.Value><ControlTemplate TargetType="{x:Type ComboBox}"><Grid><VisualStateManager.VisualStateGroups><VisualStateGroup x:Name="CommonStates"><VisualState x:Name="Normal" /><VisualState x:Name="Disabled"><Storyboard><ColorAnimationUsingKeyFrames Storyboard.TargetName="PART_EditableTextBox"
                                                Storyboard.TargetProperty="(TextElement.Foreground).(SolidColorBrush.Color)"><EasingColorKeyFrame KeyTime="0" Value="{StaticResource DisabledForegroundColor}" /></ColorAnimationUsingKeyFrames></Storyboard></VisualState></VisualStateGroup><VisualStateGroup x:Name="EditStates"><VisualState x:Name="Editable"><Storyboard><ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="PART_EditableTextBox"><DiscreteObjectKeyFrame KeyTime="0"  Value="{x:Static Visibility.Visible}" /></ObjectAnimationUsingKeyFrames><ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="ContentSite"><DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Hidden}" /></ObjectAnimationUsingKeyFrames></Storyboard></VisualState><VisualState x:Name="Uneditable" /></VisualStateGroup><VisualStateGroup x:Name="FocusStates"><VisualState x:Name="Focused"/><!-- ripped out the FocusedState Storyboard so it doesnt do anything when focused.--><VisualState x:Name="Unfocused"/></VisualStateGroup></VisualStateManager.VisualStateGroups><ToggleButton x:Name="ToggleButton"
                                          Template="{StaticResource ComboBoxToggleButtonCircle}"
                                          Grid.Column="2"
                                          Focusable="false"
                                          ClickMode="Press"
                                          IsChecked="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"/><ContentPresenter x:Name="ContentSite"
                                              IsHitTestVisible="False"
                                              Content="{TemplateBinding SelectionBoxItem}"
                                              ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}"
                                              ContentTemplateSelector="{TemplateBinding ItemTemplateSelector}"
                                              Margin="5,3,23,3"
                                              VerticalAlignment="Center" 
                                              HorizontalAlignment="Left"></ContentPresenter><TextBox x:Name="PART_EditableTextBox"  
                                     Style="{x:Null}"     
                                     Template="{StaticResource ComboBoxTextBox}"
                                     HorizontalAlignment="Left"
                                     VerticalAlignment="Center"
                                     SelectionBrush="{DynamicResource DVLinkLightBlueBrush}"
                                     VerticalContentAlignment="Center"
                                     Margin="3,3,23,3"
                                     Focusable="True" 
                                     Background="Transparent"
                                     Text="{TemplateBinding Text}"
                                     Visibility="Hidden"
                                     Foreground="Black"
                                     IsReadOnly="{TemplateBinding IsReadOnly}"/><!-- ** VerticalAlignment centers the text in the editable part of the combobox ** --><Popup x:Name="Popup"
                                   Placement="Bottom"
                                   IsOpen="{TemplateBinding IsDropDownOpen}"
                                   AllowsTransparency="True"
                                   Focusable="False"
                                   PopupAnimation="Slide"><Grid x:Name="DropDown"
                                      MinWidth="{TemplateBinding ActualWidth}"
                                      MaxHeight="{TemplateBinding MaxDropDownHeight}"><Border x:Name="DropDownBorder"
                                            BorderThickness="1" ><Border.BorderBrush><SolidColorBrush Color="{DynamicResource DVLinkBorderGray}" /></Border.BorderBrush><Border.Background><LinearGradientBrush EndPoint="0,1" StartPoint="0,0"><GradientStop Color="#e0e4e7" Offset="0"/><GradientStop Color="#a0a3a5" Offset="1"/></LinearGradientBrush></Border.Background></Border><ScrollViewer Margin="4,6,4,6"><StackPanel IsItemsHost="True" KeyboardNavigation.DirectionalNavigation="Contained" /></ScrollViewer></Grid></Popup></Grid><ControlTemplate.Triggers><Trigger Property="HasItems" Value="false"><Setter TargetName="DropDownBorder" Property="MinHeight" Value="95" /></Trigger><Trigger Property="IsGrouping" Value="true"><Setter Property="ScrollViewer.CanContentScroll" Value="false" /></Trigger><Trigger SourceName="Popup" Property="AllowsTransparency" Value="true"><Setter TargetName="DropDownBorder" Property="CornerRadius" Value="2" /><Setter TargetName="DropDownBorder" Property="Margin" Value="0,2,0,0" /></Trigger><MultiTrigger><MultiTrigger.Conditions><Condition Property="IsEditable" Value="false" /><Condition Property="SelectedItem" Value="{x:Null}" /></MultiTrigger.Conditions><Setter TargetName="PART_EditableTextBox" Property="Visibility" Value="Visible"/></MultiTrigger></ControlTemplate.Triggers></ControlTemplate></Setter.Value></Setter></Style><Style x:Key="{x:Type ComboBoxItem}"
               TargetType="{x:Type ComboBoxItem}"><Setter Property="Foreground" Value="Black" /><!-- * text displayed in the dropdown is black in colour * --><Style.Resources><SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="#00C7D5"/><!-- * when the mouse moves over a combobox entry (item), the colour is our own custom blue, instead of windows system default colour 
                note : somehow the colour parameter above does not accept DVLink defined colours
                * --></Style.Resources></Style><ControlTemplate x:Key="TextBoxBaseControlTemplate" TargetType="{x:Type TextBoxBase}" ><Border Background="{TemplateBinding Background}" BorderBrush="{DynamicResource DVLinkBorderGrayBrush}"
                BorderThickness="1" CornerRadius="2" ><ScrollViewer x:Name="PART_ContentHost"/><!-- This line will ensure that the text is displayed --></Border></ControlTemplate></Window.Resources><Border  HorizontalAlignment="Left" VerticalAlignment="Top" BorderBrush="#3d3d3d" BorderThickness="5" CornerRadius="30" MinHeight="180" Width="200"><Border.Background><LinearGradientBrush EndPoint="0,1" StartPoint="0,0"><GradientStop Color="#e0e4e7" Offset="0"/><GradientStop Color="#a0a3a5" Offset="1"/></LinearGradientBrush></Border.Background><Grid Background="Transparent" ><Grid.RowDefinitions><RowDefinition Height="60*" /><RowDefinition Height="60*" /><RowDefinition Height="45*" /></Grid.RowDefinitions><Grid.ColumnDefinitions><ColumnDefinition/></Grid.ColumnDefinitions><Image Name="DragImage" ToolTip="Drag to move application." MinHeight="17" HorizontalAlignment="Right" Margin="0,4,20,0"  VerticalAlignment="Top" Width="16" Source="..\images\MinimizeAndMove\move-button.png" MouseLeftButtonDown="DragApplicationAround"/><Label Content="Window Title" FontSize="18" Height="38" Background="#FF00C7D5" Foreground="Black" HorizontalAlignment="Left" Margin="0,27,0,0" x:Name="Name_lbl" VerticalAlignment="Top" Width="337" VerticalContentAlignment="Center" /><ListBox Grid.Row="1"  Style="{StaticResource DVLinkListboxStyle}" x:Name="lst" ScrollViewer.HorizontalScrollBarVisibility="Disabled" Background="Transparent" Margin="0,0,0,45" ItemsSource="{Binding}" DataContext="{Binding}" HorizontalContentAlignment="Stretch" BorderBrush="Transparent"><ListBox.ItemTemplate>  <DataTemplate><StackPanel Background="Transparent" Orientation="Vertical" HorizontalAlignment="Center"   Visibility="{Binding SourceVisibility}"  ><TextBlock Name="validationRule" Text="{Binding Path=Validation}" Background="Transparent" Foreground="Yellow" Margin="14,18,0,0"   Visibility="Collapsed"/><Label Name="DatabaseColumnName" Content="{Binding DatabaseColumnName}" Margin="0,0,0,0" Foreground="Black" Height="24" Width="150" Background="Transparent" /><ComboBox x:Name="comboBox1"
                                Margin="0,0,0,2"
                                Background="Transparent"
                                Foreground="Black"
                                ItemsSource="{Binding Options}"
                                BorderBrush="Transparent"
                                IsEditable="{Binding SourceMode}"
                                SelectedValue="{Binding DefaultMode, Mode=OneWay}"
                                SelectionChanged="ComboSelectionChanged"
                                Visibility="{Binding ComboVisibility}"
                                ToolTip="{Binding ValidationTooltip}"
                                Height="24" Width="150" />       <TextBox x:Name="textBox1"
                                Margin="0,0,0,2"
                                Background="Transparent"
                                Foreground="Black"
                                Visibility="{Binding TextboxVisibility}"
                                ToolTip="{Binding ValidationTooltip}" 
                                Text="{Binding DefaultMode, Mode=OneWay}"
                                TextChanged="TextBoxContentChanged"
                                Height="24" Width="147"/><Line X1="0" Y1="0" X2="170" Y2="0" Stroke="AliceBlue" StrokeThickness="0.5" Margin="0,5,0,0" VerticalAlignment="Bottom"/> </StackPanel></DataTemplate></ListBox.ItemTemplate></ListBox><Button Grid.Row="2" Grid.Column="0" Content="Annotate" BorderThickness="0" Height="29" HorizontalAlignment="Center" VerticalAlignment="Bottom" VerticalContentAlignment="Bottom" Margin="0,0,0,10" x:Name="SubmitAnnotation_btn" Width="125" Click="SubmitAnnotation_btn_Click"><Button.Background><LinearGradientBrush StartPoint="0,0" EndPoint="0,1"><LinearGradientBrush.GradientStops><GradientStopCollection><GradientStop Color="{DynamicResource DVLinkBlueGradientStop}" /><GradientStop Color="{DynamicResource DVLinkBlue}" Offset="1.0" /></GradientStopCollection></LinearGradientBrush.GradientStops></LinearGradientBrush></Button.Background><Button.Style><Style TargetType="{x:Type Button}"><Setter Property="Template"><Setter.Value><ControlTemplate TargetType="{x:Type Button}"><Border Background="{TemplateBinding Background}" CornerRadius="2"><ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/></Border></ControlTemplate></Setter.Value></Setter><Style.Triggers><Trigger Property="IsMouseOver" Value="True"><Setter Property="Background" Value="Tomato"/></Trigger></Style.Triggers></Style></Button.Style></Button></Grid></Border></Window>


User Control with combobox

$
0
0

I created a UserControl with TextBlock, TextBox and ComboBox

I have MainWindow with TabControl and this tabcontrol has several UserControls, one UserControl per TabItem

The UserControls in TabItems have the custom UserContol that I created.

Everything is working fine except the ComboBox, the ComboBox fills with data items and SelectedValue, but when I switch tabs on the MainWindow the Property that's bond to the SelectedValue gets set to null value and I can not figure out what is passing the null value, I put a break point inside the ComboBox SelectedValue setter property and the value shows null when the program hits the break point, but when I try to continue stepping through the code the code exits the Set portion of the property and goes to the Get portion, it does that twice and then goes to the next Object so I can't figure out what is passing the null value.  The SelectedValue gets correct value when I open the program, but gets nulls when I switch tabs.

I am new to WPF so I am not sure what I am doing.

I know it's probably impossible to tell what is causing this without seeing the entire program, but maybe someone had similar issue and has an advice on how to trouble shoot this or at least some suggestion on how to create an UserControl.

Here's the XAML to my custom UserControl


<UserControl x:Class="Vtsr.Views.CustomControls.VisitDataField"
             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:customControls="clr-namespace:Vtsr.Views.CustomControls"
             mc:Ignorable="d"
             x:Name="VisitDataFieldControl"
             d:DesignHeight="21" d:DesignWidth="300">

    <UserControl.Resources>
        <Style TargetType="ComboBox" x:Key="ComboBoxStyle">
            <Setter Property="Height" Value="20"></Setter>
            <Setter Property="FontSize" Value="{Binding FontSize}"></Setter>
        </Style>

        <Style TargetType="ComboBoxItem" x:Key="ComboBoxItemStyle">
            <Setter Property="BorderBrush" Value="Gray"></Setter>
            <Setter Property="BorderThickness" Value="0.0"></Setter>
        </Style>

        <Style x:Key="TextBlockStyle" TargetType="TextBlock">
            <Setter Property="FontSize" Value="{Binding FontSize}"></Setter>
            <Setter Property="FontWeight" Value="Bold"></Setter>
            <Setter Property="Margin" Value="3"></Setter>
            <Style.Triggers>
                <Trigger Property="IsMouseOver" Value="True">
                    <Setter Property="TextDecorations" Value="Underline" />
                </Trigger>
            </Style.Triggers>
        </Style>
    </UserControl.Resources>

    <Grid DataContext="{Binding ElementName=VisitDataFieldControl}">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto"></ColumnDefinition>
            <ColumnDefinition Width="*"></ColumnDefinition>
            <ColumnDefinition Width="100"></ColumnDefinition>
        </Grid.ColumnDefinitions>

        <TextBlock x:Uid="TxbLabel" x:Name="DataLabel" Margin="1,1,5,1" VerticalAlignment="Center" Width="{Binding LabelWidth}"
                           Text="{Binding DataLabelValue}" MinWidth="20" Grid.Row="0" Grid.Column="0" Style="{StaticResource TextBlockStyle}"></TextBlock>

        <customControls:FieldTextBox Text="{Binding DataField}" Grid.Row="0" Grid.Column="1" Margin="1,1,5,1" MouseRightButtonDown="TextBox_MouseRightButtonDown"></customControls:FieldTextBox>
        <ComboBox ItemsSource="{Binding UnitsList}" Grid.Row="0" Grid.Column="2" Style="{StaticResource ComboBoxStyle}" 
                                        ItemContainerStyle="{StaticResource ComboBoxItemStyle}" SelectedValue="{Binding SelectedUnit, Mode=TwoWay}">

        </ComboBox>
    </Grid>
</UserControl>

Here's code for the custom UserControl

using System;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Windows;
using System.Windows.Input;
using Vtsr.Model;

namespace Vtsr.Views.CustomControls
{
    /// <summary>
    /// Interaction logic for VisitDataField.xaml
    /// </summary>
    public partial class VisitDataField : INotifyPropertyChanged
    {
        public VisitDataField()
        {
            InitializeComponent();
        }

        public void Connect(int connectionId, object target)
        {
            throw new NotImplementedException();
        }

        public static readonly DependencyProperty LabelWidthProperty = DependencyProperty.Register("LabelWidth", typeof(int), typeof(VisitDataField), null);
        public int LabelWidth
        {
            get
            {
                return (int)GetValue(LabelWidthProperty);
            }
            set
            {
                SetValue(LabelWidthProperty, value);
            }
        }

        public static readonly DependencyProperty DataFieldProperty = DependencyProperty.Register("DataField", typeof(string), typeof(VisitDataField), null);
        public string DataField
        {
            get { return (string)GetValue(DataFieldProperty); }
            set { SetValue(DataFieldProperty, value); }
        }

        public static readonly DependencyProperty SelectedUnitProperty = DependencyProperty.Register("SelectedUnit", typeof(string), typeof(VisitDataField), null);
        public string SelectedUnit
        {
            get
            {
                return (string)GetValue(SelectedUnitProperty);
            }
            set
            {
                SetValue(SelectedUnitProperty, value);
            }
        }
        public string DataLabelValue
        {
            get
            {
                return _dataLabelValue;
            }
            set
            {
                _dataLabelValue = value;
                if (CaptionDictinaryViewModel.CaptionDictionary != null)
                _dataLabelValue = CaptionDictinaryViewModel.CaptionDictionary.ContainsKey(value) ? CaptionDictinaryViewModel.CaptionDictionary[value] : value;

                OnPropertyChanged("DataLabelValue");
            }
        }

        private string _dataLabelValue = "Data Label";

        public static readonly DependencyProperty UnitsListProperty = DependencyProperty.Register("UnitsList", typeof(ObservableCollection<string>), typeof(VisitDataField), null);

        public ObservableCollection<string> UnitsList
        {
            get { return (ObservableCollection<string>) GetValue(UnitsListProperty); }
            set { SetValue(UnitsListProperty, value);}
        }

        public event PropertyChangedEventHandler PropertyChanged;

        protected void OnPropertyChanged(string name)
        {
            var handler = PropertyChanged;

            if (handler != null)
            {
                handler(this, new PropertyChangedEventArgs(name));
            }
        }

        private void TextBox_MouseRightButtonDown(object sender, MouseButtonEventArgs e)
        {

        }
    }
}


Peter

Design View is displaying blank window for wpf in Visual Studio 2008

$
0
0

Hi,

I got the new machine, I just installed Licensed version of Microsoft Visual Studio 2008 professional. Now strange issue is happening. I copied my project from old machine to new machine and When I am opening any WPF window in design view then it is just showing blank window. Same code is working on my old machine with same visual studio 2008 but on my new machine it is not displaying it at all.

Please suggest me some solution to resolve this issue as soon as possible.


Vipul Mistry Sr. Embedded Engineer www.eInfochips.com

How get barcode reader value in TextBox

$
0
0

Hello,

How to get barcode reader value in TextBox.

WPF TooBar

$
0
0
Hey. My English is very bad, so excuse me. I need to get the toolbar design (http://www.dotnetperls.com/toolbar.png), but my VS 2013 creates toolbar design (http://arcanecode.files.wordpress.com/2007/09/wpf065.jpg). Please help me. Thnaks.

CollectionViewSource LiveGrouping - completed event?

$
0
0

Hi,

I am using the LiveGrouping feature of CollectionViewSource. It is working as I expected but I need to know when the View has been refreshed with new group data. I can't find any event that will indicate this. The Groups property of the CVS is a ReadOnlyObservableCollection and does not have a CollectionChanged event associated with it.

Any ideas?

Thanks


ChangedDaily

TabItem only shows Header in design view

$
0
0

I'm trying to create a control that derives from TabItem. It works fine at run-time, but when I view it in the designer, all I see is the header. The TabItem is in its own file (like a UserControl). It happens in both VS and Blend.

What do I need to do so I see the content of the TabItem in design view?

Thanks for your help!

Video automatically stop after 8 to 10 minutes in WPF

$
0
0
 

 Hello,

I am using Media element in wpf and playing a video in repeat behaviour but after some time my video doesn't play please suggest what i need to do so that my video never stop or hangs.
Code which i use is given below
Front End:-

<MediaElement Name="myMediaElement" IsMuted="True" Stretch="Fill" Width="768" Height="500" UnloadedBehavior="Stop" LoadedBehavior="Manual"><MediaElement.Triggers><EventTrigger RoutedEvent="MediaElement.Loaded"><EventTrigger.Actions><BeginStoryboard><Storyboard SlipBehavior="Slip"><!-- The MediaTimeline has a RepeatBehavior="Forever" which makes the media play
                 over and over indefinitely.--><MediaTimeline Name="videomediaTimeline" Storyboard.TargetName="myMediaElement"  
                                                RepeatBehavior="Forever" /></Storyboard></BeginStoryboard></EventTrigger.Actions></EventTrigger></MediaElement.Triggers></MediaElement>

Back End:-

public MainGameWindow()
        {
                InitializeComponent();             
                myMediaElement.Loaded += new RoutedEventHandler(myMediaElement_Loaded);
                   }

 

      private void playVideoWithRepet()
        {
            try
            {
                string filePath = string.Empty;
                string _pathVedioRotater = _dynamicFilePath + "TopVideoRotate.xml";
                var doc = new XmlDocument();
                doc.Load(_pathVedioRotater);
                XmlNodeList setting = doc.GetElementsByTagName("Video");
                foreach (XmlNode item in setting)
                {
                    filePath = item.ChildNodes[2].InnerText.ToString();
                }
                string videopath = _dynamicFilePath + "TopContanerVideo/" + filePath;
                videomediaTimeline.Source = new Uri(videopath, UriKind.RelativeOrAbsolute);
                doc = null;
                _pathVedioRotater = null;
                filePath = string.Empty;
                videopath = null;
                setting = null;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }



How to display dynamic data on popup for CRUD operationsi wpf c#

$
0
0

1. one page has drop down & its filled with values - rept1, rept2,rept3. On selection each I am getiing static data filled in the grid and each of those 3 has different columns bze its uses 3 different views

eg. On selection of rept1 have SourceID, BrokerID,Name,LastUpdated.  For rept2 - SourceLinkId, UserName , Brokarage etc

2. Now On I wanted design such a page which will give popup for Insert , Update for each of the rept1, rept2, rept3. Depends on selection of write click on same screen popup screen should display.

3. So can prove quick reply which will I cn design screen on dynamically which will be applicable for both rep1, rep2,rep3

Toggle Grid columns/headers based on ComboBox CheckBox Items

$
0
0

I have a WPF Grid, a Combo Box and check box fields as items of the combo box. Combobox items are the grid headers/columns. Currently, the ComboBox is binded to the columns of the Grid and Grid header is toggeled based on the toggling of the checkbox items of Combobox.

Now, I have to change this behaviour so that only some fileds are visible on the grid and those which are not visible are availabe in the Combobox as non-selected items with the fields that are visible on the grid as selected items. Toggling the checkbox items in the combobox would toggle the grid header/column visibility. Please suggest.

<local:XYZDataGrid x:Name="dataGrid" Visibility="Hidden" ShowGroupPanel="False" HorizontalAlignment="Left" VerticalAlignment="Top" SelectionMode="Extended" FontSize="10" SelectionUnit="Cell" Margin="0,40,0,0" AutoGeneratingColumn="dataGrid_AutoGeneratingColumn" CellEditEnded="dataGrid_CellEditEnded" RowEditEnded="dataGrid_RowEditEnded" PastingCellClipboardContent="dataGrid_PastingCellClipboardContent" Sorting="dataGrid_Sorting" BeginningEdit="dataGrid_BeginningEdit" CellValidating="dataGrid_CellValidating" 
                                   ClipboardPasteMode="SkipHiddenColumns, Default, AllSelectedCells, OverwriteWithEmptyValues" Pasting="dataGrid_Pasting" CopyingCellClipboardContent="dataGrid_CopyingCellClipboardContent" PreviewKeyDown="dataGrid_PreviewKeyDown" ValidatesOnDataErrors="InEditMode" ElementExporting="dataGrid_ElementExporting"><telerik:RadGridView.LayoutTransform><ScaleTransform ScaleX="{Binding Path=Value, ElementName=zoom}" ScaleY="{Binding Path=Value, ElementName=zoom}" /></telerik:RadGridView.LayoutTransform><telerik:RadGridView.SortDescriptors><telerik:SortDescriptor Member="InformationType" SortDirection="Ascending"/><telerik:SortDescriptor Member="MaterialInformationID" SortDirection="Ascending"/></telerik:RadGridView.SortDescriptors></local:XYZDataGrid>

I have a checkbox and inside it I have combobox as:

<telerik:RadComboBox EmptyText="Columns" ItemsSource="{Binding Columns, ElementName=dataGrid}" Text="Columns" Margin="750,10,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" Width="100" Height="20" SelectionChanged="RadComboBox_SelectionChanged_1"><telerik:RadComboBox.ItemTemplate>                    <DataTemplate><CheckBox Content="{Binding Header}"
                          IsChecked="{Binding IsVisible, Mode=TwoWay}" /></DataTemplate></telerik:RadComboBox.ItemTemplate></telerik:RadComboBox>

Control for supporting databinding and repeated Column headers in flowdocument -WPF

$
0
0

 Hi,

  Is there any control in wpf that support databinding with repeated column headers to display in flow document.

   currently iam using   Document.Table .It more flexible in flow document .but it does not support binding like we have in grid/Listview. if we are using grid in flow document say the grid has 100 row these rows will only fit with the height of grid with scroll option.so i need a control that fulfills data-binding with repeated column headers for  overflow to another-page. can u please go through my project on https://skydrive.live.com/?cid=96FB4F1E3660C28B&id=96FB4F1E3660C28B!103

Regards,

sajith


File Associations For a ClickOnce Application .net 4.5.1 and Windows 8.1

$
0
0

Hallo, I have a WPF .net 4.5.1 Application for clickonce deployment on Windows 8.1 machines. Unfortunately the feature "File Association" does not work. 

- I made my application offline

- Added the File Association over Visualstudio (Project-->Properties-->Publish-->Options-->File Association)

Does anyone have an idea? Thanks for help in advance.

System try in WPF C# and close operations.

$
0
0

Hi Team,

We are preparing one desktop WPF based form application for which we are implementing system tray functionality. The problem first is with "Alt + F4" and close from task bar where user can right click the application and choose close.

Other operations from UI where user can minimize or click cross button I am able to capture and enter the application in system tray. Can anyone suggest how to capture "Alt+F4" and close from task manager.

Also one problem like when application is in system tray and not on task bar, I am not able to get its Process.MainWindowHandle value, which i read is not possible when the application is only in system tray and not on task manager. How can this be done.

Thanks,

Nikhil.

erratic tab control selection changed behaviour

$
0
0

 

I have a tab control with two tab items situated on 3/4 of a wpf page. Each tab item has a number of buttons, combo boxes etc.

 

If I select the tab items (flick back and forth a couple of times), and then click on a button outside the tab control, the tab control selection changed event fires and the previous selected tab item is displayed. The impression I get is that the button click event is trying to close the tab item. How do i trap this.?

 

its somewhat similar to the tabcontrol behaviour described in this thread.

 

regards.

 

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2357515&SiteID=1

Dependency Property Binding not working...DP

$
0
0

Hi,

I have created a custom control eg QuanityCustomControl which inherits from the textbox control and have defined a DP called quantity, and need to bind this Quantity Property to the Text Property of the control.  I get an xaml parser error than binding can be done only on Dependency Property of Dependency Object. I know that Quantity is a DP, and Text is also a DP. Its a silly and small issue. 

this is the code of the custom control

 public class QuantityCustomControl : TextBox
    {

        public string Quantity
        {
            get { return (string)GetValue(QuantityProperty); }
            set { SetValue(QuantityProperty, value); }
        }

        // Using a DependencyProperty as the backing store for MyProperty.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty QuantityProperty =
            DependencyProperty.Register("QuantityProperty", typeof(string), typeof(QuantityCustomControl), new PropertyMetadata("0",QuantityChangedCallback));

        private static void QuantityChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            if (!Regex.IsMatch
            ((string)d.GetValue(e.Property), @"^[0-9]"))
            {
                d.SetValue(e.Property, "000-00-0000");
            } 

        }

    }

and this is the xaml where it is used. 

<cc:QuantityCustomControl Width="100" x:Name="ccc"  Height="25" Quantity="{Binding RelativeSource={RelativeSource Self},Path=Text}" ></cc:QuantityCustomControl>

It throws an error as mentioned in the title.


ClipToBounds depends on y-position - bug?

$
0
0

Hi there,

this days I get a strange clipping issue with .NET 4.0, perhaps it will occur also with other Versions. I drilled it back to a simple border with a rectangle inside. The same behaviour you can get with other controls, i.e. the buildin arrow controls.

If I take this elements at two different y-positions one element will be clipped the other not. If I Change the y-Position the behaviour will change.

See my code here:

<Window
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	x:Class="WpfClipError.MainWindow"
	x:Name="Window"
	Title="MainWindow"
	Width="640" Height="480"><Grid x:Name="LayoutRoot"><Border x:Name="NotClipped" Margin="360,0,0,160" HorizontalAlignment="Left" Width="80" Height="24" VerticalAlignment="Bottom" BorderBrush="Black" BorderThickness="2"><Rectangle Margin="-9,0,0,0" Fill="red" /></Border><Border x:Name="Clipped" Margin="360,0,0,115.329" HorizontalAlignment="Left" Width="80" Height="24" VerticalAlignment="Bottom" BorderBrush="Black" BorderThickness="2"><Rectangle Margin="-9,0,0,0" Fill="red" /></Border></Grid></Window>

This is the result:

ClipError

Best regards

Freisu

How to set user control as MDI in WPF

$
0
0

Dear All,

This is related to http://social.msdn.microsoft.com/Forums/en-AU/wpf/thread/efb012ac-028b-4c86-9760-cf631678055e?prof=required

Now I have create a Menu in User Control .xaml and i have called to my Window.xaml file

In menu there is an option called Add emp, when I click it , It should do the following

1. Addemp.xaml should open within the main.xaml form

2.When I click again the menu option it should not create a instance and it shoul work as like normalhyper link.

Kindly advise ,

Regards,

Selva.c

how to use expression blend

$
0
0

I have installed  visual studio 2012 update 4 From Here . but i don't find any option to use it.i want to style my wpf control
when i try to open blend then it show error

when i open the link given in that error, then i can't find any link to download blend + sketch flow.

ViewModel consuming database

$
0
0

Hello,

I am developing a Menu Application in WPF silimar to Retail Cash system and I have some dilemma.

1. Although I must consume and update my database with data from transactions, I wonder from where it is best to do it. My idea is to have a  ViewModel on Menu and from it dealing with database.

2. Sholud I have separate ViewModel for each child module to the menumodule?

Please answer to me more extensively.

Thanks

Converted WPF Project from vs2008 to vs2013

$
0
0

I have converted WPF application .net 3.5 (VS 2008)  to .Net 4.5 (VS2013) and I am trying to run this application and I am getting below exception   

A first chance exception of type 'System.TypeInitializationException' occurred in PresentationFramework.dll
Additional information: The type initializer for 'System.Windows.Application' threw an exception.

In VS2008 and .Net 3.5 its working fine but after converting I am getting this exception in VS2013 and .Net 4.5 .

Am I missing something in settings ?


Thanks.

Viewing all 18858 articles
Browse latest View live