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

WPF Ribbon - Cannot have nested BeginInit calls on the same instance

$
0
0

Hello, Everybody, 

I am stuck with a wiered issue since yesterday . I am making a WPF windows Desktop Application

using WPF Ribbon Control . I created the whole application on my machine Windows 8.1. All worked perfect. 

But When I deployed it on a Windows 7 Machine. 

It started throwing exception at start of the application. here is my simplified code, The problem i found is due to Ribbon Control. As soon as i remove the line

<Ribbon x:Name="MainRibbon" RenderTransformOrigin="0.9,0.797" >

all errors go away. I am attaching screenshots here for the erors

<Window x:Class="CAD_IMS.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:CAD_IMS"
        mc:Ignorable="d"
        Title="CAD-IMS - Hardware Inventory" Height="824.9" Width="1238" WindowStartupLocation="CenterScreen" ><Grid><Grid.Resources><BitmapImage x:Key="PasteImageResource" UriSource="/Images/paste.png" /><BitmapImage x:Key="AddImageResource" UriSource="/Images/add.png" /></Grid.Resources><Grid.RowDefinitions><RowDefinition Height="Auto"/><RowDefinition/></Grid.RowDefinitions><DockPanel x:Name="UiPanel" ScrollViewer.VerticalScrollBarVisibility="Visible" Grid.Row="1"  /><Ribbon x:Name="MainRibbon" RenderTransformOrigin="0.9,0.797" ></Ribbon></Grid></Window>

Please help me out of this . 

This error when i run on windows 7 Machine.

Thank You

.

This is when i debug with VS 2010

This is inner exception


wpf RichTextBox

$
0
0

Richtextbox is five.

Richtextbox contains letters to color.

I want to save the contents of the five Richtextboxinto one file.

is it possible?

And I want to import content from a file.




WPF Style ListView.ItemTemplate Button

$
0
0

I'm trying to change the look of a button which is in the DataTemplate of a ListView.ItemTemplate, this Button has got a Path for the content instead of a string, this works fine by default, but I can't seem to get the Path to go in my ControlTemplate in the Style. 

This is the ListView XAML

<ListView ItemsSource="{Binding Views}"
                  ItemContainerStyle="{StaticResource ListViewMenu}"
                  Grid.Row="1"
                  Grid.Column="0"
                  BorderBrush="Transparent"
                  Background="Transparent"
                  ScrollViewer.CanContentScroll="False"><!--Visibility="{DynamicResource NavigationVisible}"--><ListView.ItemsPanel><ItemsPanelTemplate><StackPanel Orientation="Vertical" /></ItemsPanelTemplate></ListView.ItemsPanel><ListView.ItemTemplate><DataTemplate><Button Command="{Binding Navigate}" Style="{StaticResource test}"><Path Data="{Binding IconGeometry}" Stretch="Fill" Width="40" Height="40" Fill="Black"/></Button></DataTemplate></ListView.ItemTemplate></ListView>

And this is the style, at the moment there is just an empty dot, which I will show in an image below the Style:

<Style TargetType="Button" x:Key="test"><Setter Property="Template"><Setter.Value><ControlTemplate><Border BorderBrush="Red" BorderThickness="2" CornerRadius="20"><ContentPresenter Width="20" Height="20" /></Border></ControlTemplate></Setter.Value></Setter></Style>

Resolution Independent WPF Application

$
0
0

I have a question regarding resolution independence in WPF. I have two images below. The first one is at a lower resolution, and the second is at a higher resolution. Here they are;

The DataGrid is simply in a TabControl which is within the main Grid. However, the bottom part of the UI is now within a ViewBox. I did this so that it would scale with the resolution. This has worked OK, it is much better than before however now on the larger resolutions the ViewBox makes the content larger than I would prefer, and the smaller resolution smaller than I prefer.

My question really would be is there a way to limit the size that the ViewBox scales up to? I would like, in the second image, for the DataGrid section to be a little larger and the second half of the content to be a bit smaller. I'm a bit hesitant to post the whole XAML because it's quite a lot of code but here's the content in the ViewBox;

<Viewbox Grid.Row="1" Grid.ColumnSpan="2" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="5,5,0,0"><Grid><Grid.RowDefinitions><RowDefinition Height="auto"/><RowDefinition Height="auto" MaxHeight="275"/></Grid.RowDefinitions><Grid.ColumnDefinitions><ColumnDefinition Width="auto"/><ColumnDefinition Width="auto" MinWidth="180"/><ColumnDefinition Width="auto" MaxWidth="400"/><ColumnDefinition Width="auto" MinWidth="200"/><ColumnDefinition Width="400"/><ColumnDefinition Width="auto" MaxWidth="160"/><ColumnDefinition /></Grid.ColumnDefinitions><Rectangle Fill="#FF5FCFBA" Stroke="Black" Grid.ColumnSpan="4" Grid.RowSpan="2"/><Label x:Name="jobTitleLabel" Content="Job" HorizontalAlignment="Left" Margin="26,10,0,5" VerticalAlignment="Center" FontSize="18" FontWeight="Bold" Grid.ColumnSpan="4"/><StackPanel Grid.Row="1" ><Label Content="Reference:" FontSize="14" HorizontalAlignment="Right" Margin="0,0,0,1" VerticalAlignment="Center" /><Label Content="Description:" FontSize="14" HorizontalAlignment="Right" Margin="0" VerticalAlignment="Center" /><Label Content="Created:" FontSize="14" HorizontalAlignment="Right" Margin="0,5,0,0" Grid.Row="1" VerticalAlignment="Center" /><Label Content="Deadline:" FontSize="14" HorizontalAlignment="Right" Grid.Row="2" VerticalAlignment="Center" Margin="-2,7,0,0" /><Label Content="Start Date:" FontSize="14" HorizontalAlignment="Right" Grid.Row="2" VerticalAlignment="Center" Margin="-2,7,0,0" /><Label Content="Employee Name:" FontSize="14" Grid.Row="3" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0,4,0,0" /><Label Content="Who's Job:" FontSize="14" Grid.Row="3" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0,7,0,0" /><Label Content="Priority:" FontSize="14" Grid.Row="3" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0,7,0,0" /></StackPanel><StackPanel Grid.Column="1" Grid.Row="1"><ComboBox x:Name="jobPresetComboBox" IsEnabled="False" IsEditable="True" Text="Pick From List"  Margin="5"  FontSize="14" Grid.Column="1" Grid.Row="4" TextBoxBase.TextChanged="ReferenceComboBoxTextInput"/><TextBox x:Name="jobTitleTextBox" Margin="5" FontSize="14" Grid.Column="1" VerticalAlignment="Center" MaxWidth="291" MaxLength="30"/><wpftk:DateTimePicker x:Name="createdPicker" AutoCloseCalendar="True"
                                            Margin="5,7,5,5" Format="Custom" FormatString="dd/MM/yyyy"
                                            FontSize="14" TextAlignment="Left"
                                            TimeFormat="LongDate" TimePickerAllowSpin="False"
                                            TimePickerShowButtonSpinner="False"
                                            TimePickerVisibility="Hidden" ShowButtonSpinner="False"
                                            AllowTextInput="False"/><wpftk:DateTimePicker x:Name="deadlinePicker" AutoCloseCalendar="True" Margin="5,8,5,5" Format="Custom" FormatString="dd/MM/yyyy" FontSize="14" TextAlignment="Left" TimeFormat="LongDate" TimePickerShowButtonSpinner="False" TimePickerAllowSpin="False" TimePickerVisibility="Hidden" ShowButtonSpinner="False"/><wpftk:DateTimePicker x:Name="startDatePicker" AutoCloseCalendar="True" Margin="5,8,5,5" Format="Custom" FormatString="dd/MM/yyyy" FontSize="14" TextAlignment="Left" TimeFormat="LongDate" TimePickerShowButtonSpinner="False" TimePickerAllowSpin="False" TimePickerVisibility="Hidden" ShowButtonSpinner="False"/><TextBox x:Name="nameTextBox" Margin="5,6,5,5" FontSize="14" Grid.Column="1" Grid.Row="3" VerticalAlignment="Center" /><ComboBox x:Name="itNameComboBox" Margin="5,7,5,5" FontSize="14" SelectedValuePath="Tag"><ComboBoxItem Content="Unallocated" Tag="Unallocated"/><ComboBoxItem Content="Adam" Tag="AdamD"/><ComboBoxItem Content="Chris" Tag="Chris"/><ComboBoxItem Content="Dan" Tag="DanD"/><ComboBoxItem Content="Emily" Tag="EmilyC"/><ComboBoxItem Content="Kit" Tag="KitL"/><ComboBoxItem Content="Matt" Tag="Matt"/></ComboBox><ComboBox x:Name="priorityComboBox" Margin="5,7,5,5" FontSize="14" SelectedValuePath="Tag"><ComboBoxItem Content="High" Tag="High"/><ComboBoxItem Content="Medium" Tag="Medium"  /><ComboBoxItem Content="Low" Tag="Low"  /></ComboBox></StackPanel><StackPanel Grid.Column="3" Grid.Row="1"><Button x:Name="addJobButton" Content="Add a New Job" Margin="5" Click="AddJob" FontSize="14" Grid.Column="1" Grid.Row="4" /><Button x:Name="updateButton" Content="Update Job Details" Margin="5" FontSize="14" Grid.Column="1" Grid.Row="4" Click="UpdateJob"/><Button x:Name="markAsCompletedButton" Content="Mark as Completed" Margin="5" FontSize="14" Click="MarkAsCompleted"/><Button x:Name="deleteButton" Content="Delete Job" Margin="5" FontSize="14" Click="DeleteJobPermanently"/><Button x:Name="excelButton" Content="Export to Excel" Margin="5" FontSize="14" Click="ExportToExcel"/><Button x:Name="restoreButton" Content="Restore Selected Job" Margin="5" FontSize="14" Visibility="Collapsed" Click="RestoreJob"/><Button x:Name="addToHistoryButton" Content="Add to History" Margin="5" FontSize="14" Visibility="Collapsed" Click="AddJobToHistory"/><Button x:Name="cancelButton" Content="Cancel Job Add" Margin="5" FontSize="14" Visibility="Collapsed" Click="CancelJobAdd"/></StackPanel><StackPanel Grid.Column="2" Grid.Row="1"><TextBox x:Name="notesTextBox" ScrollViewer.VerticalScrollBarVisibility="Visible" Margin="5" FontSize="14" VerticalAlignment="Center" TextWrapping="Wrap" AcceptsReturn="True" MinHeight="260" MaxHeight="260" MaxWidth="400" MinWidth="400"/></StackPanel><DataGrid Grid.Row="1" Grid.Column="4" x:Name="bnumDataGrid" ItemsSource="{Binding CurrentBnumsCollectionView}" MinHeight="260" MaxHeight="260"
                            CanUserAddRows="False" AutoGenerateColumns="False" SelectionChanged="BnumDataGridSelectionChanged"
                            IsReadOnly="True" Margin="5" VerticalAlignment="Top"><DataGrid.Columns><DataGridTextColumn Header="Job ID" Width="0.75*" Binding="{Binding JobID}"/><DataGridTextColumn Header="Job Description" Width="3*" Binding="{Binding JobDescription}"/></DataGrid.Columns></DataGrid><DockPanel x:Name="searchGrid" Grid.Column="4"><Label Content="Search (ID)" HorizontalAlignment="Left" Margin="5" VerticalAlignment="Center" FontSize="12" FontWeight="Bold"/><TextBox x:Name="searchBox" TextWrapping="Wrap" MinWidth="100" MaxWidth="100" FontSize="12" VerticalAlignment="Center" TextChanged="CallSearchBoxFilter"/><Label Content="Esc to clear filter" Margin="5,10,5,5" FontSize="12"/></DockPanel></Grid></Viewbox>
I was thinking about placing the entire content inside a ViewBox but this seems like an extreme measure for a scalable solution and I wasn't convinced it would work either.

How to use custom properties in a Setter (style)?

$
0
0
<c:TC Grid.Row="3"  myText="Bolt Size" myItem="{Binding BoltSizeSelected}"><c:TC.DataContext><uc:PrimaryInput/></c:TC.DataContext><c:TC.Style><Style><Setter Property="mySource" Value="{StaticResource BoltSizeM}"/><Style.Triggers><DataTrigger Binding="{Binding Inst.unit}" Value="Imperial"><Setter Property="mySource" Value="{StaticResource BoltSize}"/></DataTrigger></Style.Triggers></Style></c:TC.Style></c:TC>


mySource is a dependency property of the usercontrol TC:

        public System.Collections.IEnumerable mySource
        {
            get { return (List<string>)GetValue(mySourceProperty); }
            set { SetValue(mySourceProperty, value); }
        }

        // Using a DependencyProperty as the backing store for mySource.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty mySourceProperty =
            DependencyProperty.Register("mySource", typeof(System.Collections.IEnumerable), typeof(TC), new PropertyMetadata(null));
<ComboBox  ItemsSource="{Binding mySource,RelativeSource={RelativeSource AncestorType=UserControl}}" />

How I would be able to do <Setter Propety="mySource" ....? Thanks.


Datagrid to ViewModel to EF6

$
0
0
I am trying to use MVVM to

John Meers

Errors when adding ResourceDirectory

$
0
0

I am trying to add a resourcedirectory in App.xaml, but I cannot seem to get VS to recognise that the folder and file are there.

No matter what I do, I am returned with this:

An error occurred while finding the resource directory "Themes\Styles.xaml".

I am trying to install the WPF dark theme by Dan Pristupov found at https://github.com/DanPristupov/WpfThemes, but am having a lot of trouble simply adding the styles file as a resource.

Is this something I am doing wrong, I have done this many times with other things with no problems.

<Application x:Class="TestTheme.App"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             StartupUri="MainWindow.xaml"><Application.Resources><ResourceDictionary><ResourceDictionary.MergedDictionaries><ResourceDictionary Source="Themes\Styles.xaml" /></ResourceDictionary.MergedDictionaries></ResourceDictionary></Application.Resources></Application>


COMException - This command is not enough memory available.

$
0
0

Hi Everyone,

I have developed a WPF application with HockeyApp (third party tool - to track silent crashes). I am getting lots of crashes nearly sixty thousand crashes logged as COM exception.

Frankly, I don't have any knowledge about this and to solve this issue. So can you guys please guide me resolve this issue.

Please see the stacktrace as below;

System.Runtime.InteropServices.COMException: This command is not enough memory available. (Exception from HRESULT: 0x80070008)
   bei MS.Internal.TextFormatting.TextMetrics.FullTextLine.FormatLine(FullTextState fullText, Int32 cpFirst, Int32 lineLength, Int32 formatWidth, Int32 finiteFormatWidth, Int32 paragraphWidth, LineFlags lineFlags, FormattedTextSymbols collapsingSymbol)
   at MS.Internal.TextFormatting.TextFormatterImp.FormatLineInternal (Text Source text Source, Int32 firstCharIndex, Int32 lineLength, Double width paragraph, TextParagraphProperties paragraphProperties, text LineBreak previousLineBreak, TextRunCache textRunCache)
   at MS.Internal.TextFormatting.TextFormatterImp.FormatLine (Text Source text Source, Int32 firstCharIndex, Double width paragraph, TextParagraphProperties paragraphProperties, text LineBreak previousLineBreak, TextRunCache textRunCache)
   bei MS.Internal.Text.Line.Format(Int32 dcp, Double width, TextParagraphProperties lineProperties, TextLineBreak textLineBreak, TextRunCache textRunCache, Boolean showParagraphEllipsis)
   bei System.Windows.Controls.TextBlock.MeasureOverride(Size constraint)
   bei System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   bei System.Windows.UIElement.Measure(Size availableSize)
   bei System.Windows.Controls.Grid.MeasureCell(Int32 cell, Boolean forceInfinityV)
   bei System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean forceInfinityV, Boolean& hasDesiredSizeUChanged)
   bei System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean forceInfinityV)
   bei System.Windows.Controls.Grid.MeasureOverride(Size constraint)
   bei System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   bei System.Windows.UIElement.Measure(Size availableSize)
   bei MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element, Size constraint)
   bei System.Windows.Controls.ContentPresenter.MeasureOverride(Size constraint)
   bei System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   bei System.Windows.UIElement.Measure(Size availableSize)
   bei System.Windows.Controls.Border.MeasureOverride(Size constraint)
   bei System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   bei System.Windows.UIElement.Measure(Size availableSize)
   bei System.Windows.Controls.Control.MeasureOverride(Size constraint)
   bei System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   bei System.Windows.UIElement.Measure(Size availableSize)
   bei System.Windows.Controls.Grid.MeasureCell(Int32 cell, Boolean forceInfinityV)
   bei System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean forceInfinityV, Boolean& hasDesiredSizeUChanged)
   bei System.Windows.Controls.Grid.MeasureOverride(Size constraint)
   bei System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   bei System.Windows.UIElement.Measure(Size availableSize)
   bei System.Windows.Controls.StackPanel.StackMeasureHelper(IStackMeasure measureElement, IStackMeasureScrollData scrollData, Size constraint)
   bei System.Windows.Controls.StackPanel.MeasureOverride(Size constraint)
   bei System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   bei System.Windows.UIElement.Measure(Size availableSize)
   bei System.Windows.Controls.Grid.MeasureCell(Int32 cell, Boolean forceInfinityV)
   bei System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean forceInfinityV, Boolean& hasDesiredSizeUChanged)
   bei System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean forceInfinityV)
   bei System.Windows.Controls.Grid.MeasureOverride(Size constraint)
   bei System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   bei System.Windows.UIElement.Measure(Size availableSize)
   bei System.Windows.Controls.Grid.MeasureCell(Int32 cell, Boolean forceInfinityV)
   bei System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean forceInfinityV, Boolean& hasDesiredSizeUChanged)
   bei System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean forceInfinityV)
   bei System.Windows.Controls.Grid.MeasureOverride(Size constraint)
   bei System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   bei System.Windows.UIElement.Measure(Size availableSize)
   bei System.Windows.Controls.Grid.MeasureOverride(Size constraint)
   bei System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   bei System.Windows.UIElement.Measure(Size availableSize)
   bei MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element, Size constraint)
   bei System.Windows.Controls.ContentPresenter.MeasureOverride(Size constraint)
   bei System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   bei System.Windows.UIElement.Measure(Size availableSize)
   bei System.Windows.Controls.Border.MeasureOverride(Size constraint)
   bei System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   bei System.Windows.UIElement.Measure(Size availableSize)
   bei System.Windows.Controls.Control.MeasureOverride(Size constraint)
   bei System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   bei System.Windows.UIElement.Measure(Size availableSize)
   bei System.Windows.Controls.Grid.MeasureOverride(Size constraint)
   bei System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   bei System.Windows.UIElement.Measure(Size availableSize)
   bei System.Windows.Controls.Grid.MeasureCell(Int32 cell, Boolean forceInfinityV)
   bei System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean forceInfinityV, Boolean& hasDesiredSizeUChanged)
   bei System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean forceInfinityV)
   bei System.Windows.Controls.Grid.MeasureOverride(Size constraint)
   bei System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   bei System.Windows.UIElement.Measure(Size availableSize)
   bei System.Windows.Controls.Grid.MeasureCell(Int32 cell, Boolean forceInfinityV)
   bei System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean forceInfinityV, Boolean& hasDesiredSizeUChanged)
   bei System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean forceInfinityV)
   bei System.Windows.Controls.Grid.MeasureOverride(Size constraint)
   bei System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   bei System.Windows.UIElement.Measure(Size availableSize)
   bei System.Windows.Controls.Grid.MeasureCell(Int32 cell, Boolean forceInfinityV)
   bei System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean forceInfinityV, Boolean& hasDesiredSizeUChanged)
   bei System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean forceInfinityV)
   bei System.Windows.Controls.Grid.MeasureOverride(Size constraint)
   bei System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   bei System.Windows.UIElement.Measure(Size availableSize)
   bei System.Windows.Controls.Grid.MeasureCell(Int32 cell, Boolean forceInfinityV)
   bei System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean forceInfinityV, Boolean& hasDesiredSizeUChanged)
   bei System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean forceInfinityV)
   bei System.Windows.Controls.Grid.MeasureOverride(Size constraint)
   bei System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   bei System.Windows.UIElement.Measure(Size availableSize)
   bei System.Windows.Controls.Grid.MeasureCell(Int32 cell, Boolean forceInfinityV)
   bei System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean forceInfinityV, Boolean& hasDesiredSizeUChanged)
   bei System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean forceInfinityV)
   bei System.Windows.Controls.Grid.MeasureOverride(Size constraint)
   bei System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   bei System.Windows.UIElement.Measure(Size availableSize)
   bei System.Windows.Controls.Grid.MeasureOverride(Size constraint)
   bei System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   bei System.Windows.UIElement.Measure(Size availableSize)
   bei System.Windows.Controls.Grid.MeasureOverride(Size constraint)
   bei System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   bei System.Windows.UIElement.Measure(Size availableSize)
   bei MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element, Size constraint)
   bei System.Windows.Controls.ContentPresenter.MeasureOverride(Size constraint)
   bei System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   bei System.Windows.UIElement.Measure(Size availableSize)
   bei System.Windows.Documents.AdornerDecorator.MeasureOverride(Size constraint)
   bei System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   bei System.Windows.UIElement.Measure(Size availableSize)
   bei System.Windows.Controls.Border.MeasureOverride(Size constraint)
   bei System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   bei System.Windows.UIElement.Measure(Size availableSize)
   bei System.Windows.Window.MeasureOverrideHelper(Size constraint)
   bei System.Windows.Window.MeasureOverride(Size availableSize)
   bei System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   bei System.Windows.UIElement.Measure(Size availableSize)
   bei System.Windows.ContextLayoutManager.UpdateLayout()
   bei System.Windows.UIElement.UpdateLayout()
   bei System.Windows.Controls.VirtualizingStackPanel.<>c__DisplayClass94_0.<InitializeViewport>b__0()
   bei System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   bei System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
Caused by: System.Runtime.InteropServices.COMException: This command is not enough memory available. (Exception from HRESULT: 0x80070008)
   bei System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo)
   bei System.Runtime.InteropServices.Marshal.ThrowExceptionForHR(Int32 errorCode, IntPtr errorInfo)
   bei MS.Internal.Text.TextInterface.Native.Util.ConvertHresultToException(Int32 hr)
   bei MS.Internal.Text.TextInterface.Font.CreateFontFace()
   bei MS.Internal.Text.TextInterface.Font.AddFontFaceToCache()
   bei MS.Internal.Text.TextInterface.Font.GetFontFace()
   bei System.Windows.Media.GlyphTypeface..ctor(Font font)
   bei MS.Internal.FontFace.PhysicalFontFamily.MapGlyphTypeface (Font Style style, Font Weight Weight, Font Stretch stretch, Character Buffer Range charString, CultureInfo digitCulture, Int32 & Advance, Int32 & nextValid)
   bei MS.Internal.Shaping.TypefaceMap.MapByFontFaceFamily(CharacterBufferRange unicodeString, CultureInfo culture, CultureInfo digitCulture, IFontFamily fontFamily, FontStyle canonicalStyle, FontWeight canonicalWeight, FontStretch canonicalStretch, PhysicalFontFamily& firstValidFamily, Int32& firstValidLength, IDeviceFont deviceFont, Boolean nullFont, Double scaleInEm, SpanVector scaledTypefaceSpans, Int32 firstCharIndex, Boolean ignoreMissing, Int32& nextValid)
   bei MS.Internal.Shaping.TypefaceMap.MapByFontFamily(CharacterBufferRange unicodeString, CultureInfo culture, CultureInfo digitCulture, IFontFamily fontFamily, CanonicalFontFamilyReference canonicalFamilyReference, FontStyle canonicalStyle, FontWeight canonicalWeight, FontStretch canonicalStretch, PhysicalFontFamily& firstValidFamily, Int32& firstValidLength, IDeviceFont deviceFont, Double scaleInEm, Int32 recursionDepth, SpanVector scaledTypefaceSpans, Int32 firstCharIndex, Int32& nextValid)
   bei MS.Internal.Shaping.TypefaceMap.MapOnceByFontFamilyList(CharacterBufferRange unicodeString, CultureInfo culture, CultureInfo digitCulture, FontFamily[] familyList, PhysicalFontFamily& firstValidFamily, Int32& firstValidLength, IDeviceFont deviceFont, Double scaleInEm, Int32 recursionDepth, SpanVector scaledTypefaceSpans, Int32 firstCharIndex, Int32& nextValid)
   bei MS.Internal.Shaping.TypefaceMap.MapByFontFamilyList(CharacterBufferRange unicodeString, CultureInfo culture, CultureInfo digitCulture, FontFamily[] familyList, PhysicalFontFamily& firstValidFamily, Int32& firstValidLength, IDeviceFont deviceFont, Double scaleInEm, Int32 recursionDepth, SpanVector scaledTypefaceSpans, Int32 firstCharIndex, Int32& nextValid)
   bei MS.Internal.Shaping.TypefaceMap.MapByFontFamilyName(CharacterBufferRange unicodeString, CultureInfo culture, CultureInfo digitCulture, String familyName, Uri baseUri, PhysicalFontFamily& firstValidFamily, Int32& firstValidLength, IDeviceFont deviceFont, Double scaleInEm, Int32 fontMappingDepth, SpanVector scaledTypefaceSpans, Int32 firstCharIndex, Int32& nextValid)
   bei MS.Internal.Shaping.TypefaceMap.MapByFontFamily(CharacterBufferRange unicodeString, CultureInfo culture, CultureInfo digitCulture, IFontFamily fontFamily, CanonicalFontFamilyReference canonicalFamilyReference, FontStyle canonicalStyle, FontWeight canonicalWeight, FontStretch canonicalStretch, PhysicalFontFamily& firstValidFamily, Int32& firstValidLength, IDeviceFont deviceFont, Double scaleInEm, Int32 recursionDepth, SpanVector scaledTypefaceSpans, Int32 firstCharIndex, Int32& nextValid)
   bei MS.Internal.Shaping.TypefaceMap.MapOnceByFontFamilyList(CharacterBufferRange unicodeString, CultureInfo culture, CultureInfo digitCulture, FontFamily[] familyList, PhysicalFontFamily& firstValidFamily, Int32& firstValidLength, IDeviceFont deviceFont, Double scaleInEm, Int32 recursionDepth, SpanVector scaledTypefaceSpans, Int32 firstCharIndex, Int32& nextValid)
   bei MS.Internal.Shaping.TypefaceMap.MapByFontFamilyList(CharacterBufferRange unicodeString, CultureInfo culture, CultureInfo digitCulture, FontFamily[] familyList, PhysicalFontFamily& firstValidFamily, Int32& firstValidLength, IDeviceFont deviceFont, Double scaleInEm, Int32 recursionDepth, SpanVector scaledTypefaceSpans, Int32 firstCharIndex, Int32& nextValid)
   bei MS.Internal.Shaping.TypefaceMap.MapItem(CharacterBufferRange unicodeString, CultureInfo culture, Span itemSpan, SpanVector`1& cachedScaledTypefaceIndexSpans, Int32 ichItem)
   bei MS.Internal.Shaping.TypefaceMap.GetShapeableText(CharacterBufferReference characterBufferReference, Int32 stringLength, TextRunProperties textRunProperties, CultureInfo digitCulture, Boolean isRightToLeftParagraph, IList`1 shapeableList, IShapeableTextCollector collector, TextFormattingMode textFormattingMode)
   bei MS.Internal.Shaping.GlyphingCache.GetShapeableText(Typeface typeface, CharacterBufferReference characterBufferReference, Int32 stringLength, TextRunProperties textRunProperties, CultureInfo digitCulture, Boolean isRightToLeftParagraph, IList`1 shapeableList, IShapeableTextCollector collector, TextFormattingMode textFormattingMode)
   at glyphingCache, Character Buffer Reference character reference buffer, Int32 length, Boolean rightToLeft, Boolean isRightToLeftParagraph, CultureInfo digit culture, TextModifierScope textModifierScope, Text Formatting Text Formatting Mode mode, Boolean isSideways)
   bei MS.Internal.TextFormatting.TextStore.CreateTextLSRuns(TextRunInfo runInfo, IList`1 textEffects, CultureInfo digitCulture, Int32 offsetToFirstChar, Int32 stringLength, Int32 uniformBidiLevel, TextFormattingMode textFormattingMode, Boolean isSideways, Int32& lastBidiLevel)
   bei MS.Internal.TextFormatting.TextStore.CreateLSRuns(TextRunInfo runInfo, IList`1 textEffects, CultureInfo digitCulture, Int32 offsetToFirstChar, Int32 stringLength, Int32 uniformBidiLevel, TextFormattingMode textFormattingMode, Boolean isSideways, Int32& lastBidiLevel, Int32& textRunLength)
   bei MS.Internal.TextFormatting.TextStore.CreateLSRunsUniformBidiLevel (SpanVector runInfoVector, SpanVector textEffectsVector, Int32 runInfoFirstCp, Int32 ichUniform, Int32 cchUniform, Int32 uniformBidiLevel, Text Formatting Mode text formatting mode, Boolean isSideways, Int32 & lastBidiLevel)
   at MS.Internal.TextFormatting.TextStore.FetchLSRun (Int32 lscpFetch, Text Formatting Text Formatting Mode mode, Boolean isSideways, Plsrun & plsrun, Int32 & lsrunOffset, Int32 & lsrunLength)
   (pols IntPtr, Int32 lscpFetch, Int32 fIsStyle, IntPtr pstyle, char * pwchTextBuffer, Int32 cchTextBuffer, Int32 & fIsBufferUsed, char * & pwchText, Int32 & cchText, Int32 & fIsHidden, LsChp & lschp, IntPtr & lsplsrun) at MS.Internal.TextFormatting.LineServicesCallbacks.FetchRunRedefined


WPF application leaks memory when switching between user accounts

$
0
0

Steps to reproduce:

  1. I log into a non-admin user account (Windows 10 machine)
  2. I launch a WPF application (an empty WPF application from the default VS templates will do)
  3. I switch users from my non-admin account to my admin account
  4. Open the task manager and watch the memory consumption of my WPF application grow

Other notes:

  • Memory consumption goes up at about .1 MB a second
  • I've reproduced this bug with .NET framework versions 4.5 and 4.6
  • I had the bug tested by 3 users on 3 "uncorrelated" machines (all running Windows 10) and the bug reproduced for 2 out of the 3 users
  • The bug does not reproduce if I run the app in my admin account and switch to my non-admin account 

Dynamic TabControl in MVVM

$
0
0

Hi,

I have an MVVM application with a TabControl. The content of the tab is a UserControl i created.

I created a TabControl and binded the ItemSource to a collection in the ViewModel like this:

<TabControl HorizontalAlignment="Left" Height="696" Margin="429,0,0,32" VerticalAlignment="Bottom" Width="552" ItemsSource="{Binding TabCollection}"/>

In the ViewModel I initialize  the collection in the constructor :

 //**** Initilize TabCollection with fake data (temporary)
            TabCollection.Add(new TabItem { Header = "בדיקה1", Content = new CatagoryTab() });
            TabCollection.Add(new TabItem { Header = "בדיקה2", Content = new CatagoryTab() });

So two questions:

1. which class or part of class should be responsible for populating the TabCollection with data? Should I, instead of the above example, create a Model for the TabCollection which will be responsible to populate itself in the constructor? Or is it fine like this?

2. Should the UserControl have it's own ViewModel?

Thank you very much!

Support for XBAP by Microsoft

$
0
0

Hello Everyone,

We currently are using the XBAP application on IE 11 which was initially developed in 2009 and are maintaining it since it helps us integrate with a third-party web application.

Would like to know if XBAP is still being actively supported by Microsoft? The reason is we're facing some issues with reading secure cookies and need to probably raise a ticket with Microsoft so would be helpful to know this information.

Thanks,

Smeetha

Dynamic Width

$
0
0

I have a TextBox inside a StackPanel, and I an trying to get the textbox to fit the window dynamically so when it is resized, the textbox follows.

I am used to building websites, but obviously width=100% isn't going to work here, but setting the HorizontalAllignment to Stretch as I found online also did nothing.

I added the line to my StackPanel, and that is now 100% width, but it isn't working for the TextBox.

<StackPanel Orientation="Horizontal" Margin="0,0,10,0" HorizontalAlignment="Stretch"><Label Content="Description " /><TextBox HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="0,2,10,2"/></StackPanel>

TabItem Header Click not Always Firing

$
0
0

I wanted to find a method of firing an event when the TabItem of a Page is selected. I had a look around and found that placing a Label on the header and using MouseLeftButtonDown was a way of making this event fire. The XAML looks like this;

<TabItem><TabItem.Header><Label Content="Archived Jobs"  MouseLeftButtonDown="CallArchivedJobsTabItemSelected"/></TabItem.Header></TabItem>

There is an issue with this fix though, in that if the user clicks in a specific place under the Label they will be able to select the TabItem without the event firing. How can I program this differently to ensure that they cannot bypass the event firing? The kind of code that it is firing is something like;

if(tabItem1.IsSelected == true)
{
 // Do Something
}

if(tabItem2.IsSelected == true)
{
 // Do Something
}

I have tried using GotFocus on the TabItem and SelectionChanged on the TabControl. GotFocus seemed to freeze the UI and SelectionChanged wouldn't let me select from a TabItems DataGrid either.


Trigger when vertical scrollbar thumb height is less than some value

$
0
0

I have custom scrollbar where thumb (moving part) has image in its center. I need to collapse image when thumb height is less than image height. It seems that there is no way to trigger on current height of thumb (i tried height and actualheight properties, both are wrong).

<local:CutoffConverter x:Key="ThumbHeightConverter" Cutoff="34" />

<Style x:Key="ScrollBarThumb" TargetType="{x:Type Thumb}">
        <Setter Property="SnapsToDevicePixels" Value="True" />
        <Setter Property="OverridesDefaultStyle" Value="True" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Thumb}">
                    <Border Name="ThumbBorder" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
                        <Border.Style>
                            <Style TargetType="{x:Type Border}">
                                <Setter Property="Background" Value="{StaticResource VScrollBarThumbNormalBrush}" />
                            </Style>
                        </Border.Style>
                        <Grid>
                            <Image Name="ThumbImage" Stretch="Fill" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" >
                                <Image.Style>
                                    <Style TargetType="{x:Type Image}">
                                        <Setter Property="Width" Value="26" />
                                        <Setter Property="Height" Value="34" />
                                        <Setter Property="MinHeight" Value="34" />
                                        <Setter Property="MaxHeight" Value="34" />
                                        <Setter Property="Source" Value="{StaticResource VScrollBarThumbNormal}" />
                                        <Style.Triggers>
                                            <DataTrigger Binding="{Binding Path=ActualHeight,
                                                RelativeSource={RelativeSource Mode=FindAncestor,
                                                AncestorType={x:Type Thumb}},
                                                Converter={StaticResource ThumbHeightConverter}}" Value="True">
                                                <Setter Property="Visibility" Value="Collapsed" />
                                            </DataTrigger>
                                        </Style.Triggers>
                                    </Style>
                                </Image.Style>
                            </Image>
                        </Grid>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter TargetName="ThumbImage" Property="Source" Value="{StaticResource VScrollBarThumbHover}" />
                            <Setter TargetName="ThumbBorder" Property="Background" Value="{StaticResource VScrollBarThumbHoverBrush}" />
                        </Trigger>
                        <Trigger Property="IsDragging" Value="True">
                            <Setter TargetName="ThumbImage" Property="Source" Value="{StaticResource VScrollBarThumbPressed}" />
                            <Setter TargetName="ThumbBorder" Property="Background" Value="{StaticResource VScrollBarThumbPressedBrush}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>


Converter code:

    public class CutoffConverter : IValueConverter
    {
        public int Cutoff { get; set; }

        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (!(value is double))
                return false;
            if (Double.IsNaN((double)value))
                return false;
            return ((int)((double)value)) < Cutoff;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }

How to create your own EVENT-WPF

$
0
0

hi, this is something i have never learned before but i have seen it been done...

how do i add an event onto a control that doesnt have that event,  

example, wpf grid has only a "grid.MouseDown" event... how do, if possible add my own "grid.MouseDoubleClick"

can anyone show me please...


Remove selected item from WPF ListBox and ItemSource

$
0
0

I have this working but I'm guessing (hoping?) there's an easier way.

I have a ListBox on a WPF form with Extended Selection mode and the user can remove items from that ListBox. For easy sorting the list items are stored in a List(Of String) called and LstExifEditTags2ListSort and ListBox is filled like this:

Me.LstExifEditTags2.ItemsSource = LstExifEditTags2ListSort

I know I need to manipulate List(Of String) once it becomes the item source and Initially I had this to remove the items:

For Each LstItem In Me.LstExifEditTags2.SelectedItems
      LstExifEditTags2ListSort.Remove(LstItem)
Next
Me.LstExifEditTags2.Items.Refresh()

But that simply deleted the first instance from the list that matched that particular selected item string. So, if the user selected an item near the end of the list that was the same as an item near the start of the list, the first one (near the start of the list) would get deleted and NOT the one the user actually selected.

I couldn't find a way to get index of the selected item in the ListBox so as to match it up with an item in the List(Of String). I ended up looping backward through the selected items, then looping backward through the List(Of String) while the List(Of String).Equals was either equal to the selected item or the counting variable was less than 0. Thusly:

                For i = Me.LstExifEditTags2.SelectedItems.Count - 1 To 0 Step -1
                    LstCount = LstExifEditTags2ListSort.Count - 1
                    While LstCount > -1 And Not LstExifEditTags2ListSort.Item(LstCount).Equals(Me.LstExifEditTags2.SelectedItems(i))
                        LstCount -= 1
                    End While
                    If LstExifEditTags2ListSort.Item(LstCount).Equals(Me.LstExifEditTags2.SelectedItems(i)) Then
                        LstExifEditTags2ListSort.RemoveAt(LstCount)
                    End If
                Next i

So, my question is two fold:

1. Is there an easier way to do this?? (seems like there should be)

2. Does the .Equals simply do a string comparison or is it doing something more like comparing the position of the two things in each list.

Many thanks for any insight that can be offered.

Best,
Ken



Using Transform Property in Trigger Setter's

$
0
0

Hi,

I just tried to apply some values to the transform properties in the trigger setter. Unfortunately it is throwing the error in the intellisense as "Nested types are not supported: (RenderTransform.TransformGroup[0]".

Hereby, I have shared the code,

<ControlTemplate TargetType="{x:Type ToggleButton}"><Grid Height="Auto"><!-- Other Codes --><Border Grid.Column="1"><Path x:Name="PathData"
                          Data="M0,0L25.194,16 0,32z"
                          Fill="#FFFFFFFF"
                          RenderTransformOrigin="0.5,0.5"
                          Stretch="Uniform"><TransformGroup><TransformGroup.Children><RotateTransform Angle="0" /><ScaleTransform ScaleX="1" ScaleY="1" /></TransformGroup.Children></TransformGroup></Path></Border></Grid><ControlTemplate.Triggers><Trigger Property="IsChecked" Value="True"><Setter TargetName="PathData" Property="(RenderTransform.TransformGroup[0].Angle)" Value="90" /></Trigger></ControlTemplate.Triggers></ControlTemplate>

However I can able to get this one by replacing the Data of the Path in the trigger.  

But I want to know, why I am not getting this one by using the above method.

Thanks in advance.


NANDAKUMAR.T

getting the sender from Addhandler WPF VB

$
0
0

WPF related:

Another question... (This is a problem i come accoss VERY often, but i usually try to work around it)

i have a loop lets say:

dim MyStack as new stackpanel
MyStack.orientation = orientation.Vertical

for each Filestring as string in system.io.directories.getDirectories("C:\", "*.*" , TopDirectories)
dim MyButton as new button
MyButton.Content = Filestring.remove(0,(Filestring.lastIndexOf("\")+1))'That is the get ONLY the name of the folder.
A
ddHandler Mybutton.Click,AddressOf MyButtonClick
'
MystackPanel.Children.Add(MyButton)

 Next

and then:

Private Sub MybuttonClick()

//''Do some stuff
End Sub

My question is, that im NOT allowed to link an address with values in like the sender or event args, i.e i cant link this:
Private Sub MyButtonClick (Byval sender as Object, Byval e as System.Windows.RoutedEventArgs)
End Sub

VB wil Give me a big error... now thats fine and dandy,,,, but my question is if im not allowed to send the sender, will will i be able to use the SENDER as button in the event i addressed, because its not publically declared, so i cant use it that way.

is it possible to send the button to the event as sender in able to use it  or not?

richTextbox

$
0
0

 

FileStream fileStream = new FileStream("RTBDocument.rtf", FileMode.Open);
TextRange range = new TextRange(richtextBox1.Document.ContentStart, richtextBox1.Document.ContentEnd);
range.Load(fileStream, DataFormats.Rtf);

i am Load the RTBDocument.rtf file to richtextBox1.

richtextBox1 search only "I'm happy"

And I want to be display "I'm happy(with Color )"  in richTextBox2.


richTextBox1 (good morning nice to meet you I'm happy..) -> find (I'm happy) -> richTextBox2 (I'm happy)Show


please answer about my question.

 

custom grouping

$
0
0

Hi, it's for a health application  .


Let's say that i have these  entities

 public partial class EXAMINATION
{
        public int ID_EXAMINATION { get; set; }
        public int ID_PATIENT { get; set; }
        public System.DateTime DT { get; set; }
       public List<TEST> TESTS { get; set; }
}

 public partial class TEST
{  
        public int ID_TEST{ get; set; }
        public string TITLE { get; set; }
 }
 so each EXAMINATION may have 0..n TESTs

and i have  a datagrid bound to ObservableCollection<EXAMINATION> .

what i want to get is , a grouping based on TEST

any help is welcome

 
Viewing all 18858 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>