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

Storyboard loading from extrnal file

$
0
0

I've external xaml file witch scene,cameras and storyboard everything is warped witch <Viewport3D>....</Viewport3D>.

I'm loading my model.xaml file with

                try
                {
                    StreamReader mysr = new StreamReader(path);
                    _grid.Children.Add(XamlReader.Load(mysr.BaseStream) as Viewport3D);
                }
                catch

And i want to start my application using button

private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            Storyboard sb = this.FindResource("MoveSB") as Storyboard;            
            sb.Begin();
        }
 

but visual can't find my resource normally i would write  this.myViewPort.FindResource("MoveSB") as Storyboard; 

I probably have to call it in different way but have no idea how.


ClickOnce is crashing after deployment

$
0
0

Hi all,

I'm having a very weird issue today with ClickOnce. After publishing, the application no longer starts from the Start Menu. The same is happening on my workmate's computer. If I search for the executable in the manifest directory of my profile and double-click it, it opens just fine. So it is certainly something to do with the ClickOnce manifest locator. I verified it is the latest update by sorting the directories by date as well, and tested the app to make sure it was the latest version with my new features. 

Edit: I hasten to add that if I try to attach to the process in Visual Studio debugger before it crashes, the process closes before my debugger can catch it. I will reply to this with the output from the AppCrash Report.wer associated with this manifest.

Edit: I do not have the Kensington mouse driver, before anyone points me to that thread. I verified this in many ways.

What's going on?

.net version: 4.5, using WPF in visual studio 2012

-Brandon



Debugging "System.InvalidOperationException: The sum of AccelerationRatio and DecelerationRatio must be less than or equal to one."

$
0
0

Hi all,

I'm seeing crash reports from a small percentage of my users with this exception on startup:

System.Windows.Markup.XamlParseException: Set property 'System.Windows.FrameworkElement.Style' threw an exception. ---> System.InvalidOperationException: The sum of AccelerationRatio and DecelerationRatio must be less than or equal to one.
  at System.Windows.Media.Animation.Timeline.ValidateTimeline()
  at System.Windows.Media.Animation.Timeline.FreezeCore(Boolean isChecking)
  at System.Windows.Freezable.Freeze(Boolean isChecking)
  at System.Windows.Media.Animation.TimelineCollection.FreezeCore(Boolean isChecking)
  at System.Windows.Freezable.Freeze(Boolean isChecking)
  at System.Windows.PropertyMetadata.DefaultFreezeValueCallback(DependencyObject d, DependencyProperty dp, EntryIndex entryIndex, PropertyMetadata metadata, Boolean isChecking)
  at System.Windows.Freezable.FreezeCore(Boolean isChecking)
  at System.Windows.Media.Animation.Animatable.FreezeCore(Boolean isChecking)
  at System.Windows.Media.Animation.Timeline.FreezeCore(Boolean isChecking)
  at System.Windows.Freezable.get_CanFreeze()
  at System.Windows.Media.Animation.BeginStoryboard.Seal()
  at System.Windows.TriggerAction.Seal(TriggerBase containingTrigger)
  at System.Windows.TriggerActionCollection.Seal(TriggerBase containingTrigger)
  at System.Windows.TriggerBase.Seal()
  at System.Windows.DataTrigger.Seal()
  at System.Windows.TriggerCollection.Seal()
  at System.Windows.Style.Seal()
  at System.Windows.StyleHelper.UpdateStyleCache(FrameworkElement fe, FrameworkContentElement fce, Style oldStyle, Style newStyle, Style& styleCache)
  at System.Windows.FrameworkElement.OnStyleChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
  at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
  at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
  at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args)
  at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType)
  at System.Windows.DependencyObject.SetValueCommon(DependencyProperty dp, Object value, PropertyMetadata metadata, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType, Boolean isInternal)
  at System.Windows.Baml2006.WpfKnownMemberInvoker.SetValue(Object instance, Object value)
  at MS.Internal.Xaml.Runtime.ClrObjectRuntime.SetValue(XamlMember member, Object obj, Object value)
  at MS.Internal.Xaml.Runtime.ClrObjectRuntime.SetValue(Object inst, XamlMember property, Object value)

The problem is I'm unable to reproduce the crash, and I can't figure out where it is actually happening from the stack trace. 

Can someone tell me how I would go about troubleshooting this issue with the user so I can narrow down what needs fixing?

Decorate editable text in a TextBox control

$
0
0

My planned application is about entering short texts for a series of keys. The texts can contain certain markup the references to other texts or data. It can also contain invisible characters such as regular spaces, non-breaking spaces, line breaks and so on. The text is otherwise unformatted and is in fact only stored as a regular string.

I would like to have the text decorated by a number of rules:

  1. Anything between an opening and closing brace { and } should be marked with a different background colour. This colour doesn't need to be visible when the text is selected.
  2. I will parse the text within the { and } characters and determine whether it is valid or not. If it's invalid, parts of it should be underlined with red colour, preferably with that wiggling line like syntax errors in the Visual Studio code editor.
  3. Invisible characters (I know which, mostly spaces, within the full Unicode range) should be made visible by displaying a grey replacement character on them, much like the comparable feature in Word. If possible, the original spacing should be preserved.

This decoration should only be displayed within the TextBox control, it can be computed whenever the text is displayed and will not be stored with the data. It's read only.

I've searched for solutions for a while now and found two different approaches:

CodeBox and its derivates (I've tried wpfsyntax on CodePlex), which basically prevents regular TextBox contents from being rendered and renders it on its own. It is very laggy, it seems to update the text with a timer which seems highly inefficient to me.

The RichTextBox control should be able to display my background colour, not sure about the (wiggling) red underlining. I've tried to replace all spaces by something else in it, with a different colour. That works only once, the next time my replacements were replaced again and lost their colour... But even worse, the replacement characters were also copied out through the clipboard, which is definitely not desired! And since they're actually in the text, the spacings could change.

So what solution would you recommend me? I thought that some kind of decoration layer above and beneath the actual text layer should be fine. It must scroll with the text of course and it should update reasonable fast. That layer could then render only the markers and replacement characters at the right position. I just don't know whether it's possible to find the on-screen locations of single characters or character ranges (including those spanning multiple lines).

Any ideas?

Update: Another idea I had was to modify/override the rendering of a Run inside a RichTextBox to decorate it or keep the original text but display something entirely else, but that doesn't seem to be possible.

How to handle tab navigation when a disabled control get focused.

$
0
0

Hi,

In a panel containing a DataGrid and some Buttons, I have problems getting tab navigation to work correct.

When focus leaves the DataGrid in a tabbing sequence, the next control in the tab order is a button that is disabled through binding - causing focus to be set to the panels parent control, and not to the nextenabled control in the tab order.

The problems seems to be that the button is disabled in the same operation that is changing focus. Or stated otherwise: Tabbing out of the datagrid unselects a row, which then disables the button through vm-binding.

Note that other buttons further down in the tab order are enabled, but they do not get focused. 

Hope this is a well known problem with a good solution.


Binding Visible/Collapsed to ContentPresenters within a TabControl.

$
0
0

Hello,

I've been struggling with this WPF issue for a few days, and I'm pretty much at the end of my rope. I'm a WPF newbie...

- I have two DataTemplates declared as Window.Resources.

- I have a TabControl with two ContentPresenter controls within a Grid, within the ContentTemplate/DataTemplate section. If I manually specify eithers Visibility to "Visible" then the DataTemplate bound to that specific presenter appears as it should (assuming the other one is set to "Hidden"). So the DataTemplates themselves, and the general functionality of the ContentPresenters is wired just fine.

- What I need to do is, based on two buttons to the left of the TabControl in my window, is show/hide the ContentPresenters based on which button was clicked. So if a user clicks "Patient" the PatientContentPresenter is visible (along with it's bound DataTemplate), if the user clicks on "Family" then the PatientContentPresenter collapses, and the FamilyContentPresenter becomes visible. So in essance there's 2 possible Views that could appear withing the TabControls tab.

- The issue seems to be the RaisePropertyChanged not having any effect on the the TabControl, and re-drawing the screen with the correct ContentPresenter active. I added debug statements that tell me they are being set correctly in the ViewModel, but the UI is not updating.

If anyone can tell me why the screen isn't updating to show the correct ContentPresenter, I'd be very grateful....here is the code:

XAML:

    <Window.Resources>

       <DataTemplate x:Key="PatientDataTemplate">

           <Views:PatientRecordView x:Name="header" Grid.Row="0" Grid.Column="1" />

       </DataTemplate>

       <DataTemplate x:Key="FamilyDataTemplate">

           <Views:FamilyRecordView x:Name="header" Grid.Row="0" Grid.Column="1" />

       </DataTemplate>

   </Window.Resources>

 

       <TabControl SelectedItem="{Binding SelectedCall}"

                   ItemsSource="{Binding Calls }"

                   SelectionChanged="Selector_OnSelectionChanged"

                   Margin="0"

                   Grid.Row="0" Grid.Column="1" Padding="0" BorderThickness="1,0,1,1" Background="#1d1d1d"

                    Name="MainTabControl">

           <TabControl.ItemTemplate>

               <DataTemplate>

                   <TextBlock Height="20" FontSize="12" Foreground="White" Text="{Binding DisplayName}" />

               </DataTemplate>

           </TabControl.ItemTemplate>

           <TabControl.ContentTemplate>

               <DataTemplate><!-- see above for Windows.Resources for Patient and Family templates -->

                    <Grid x:Name="ContentPresenterGrid">

                       <ContentPresenter x:Name="FamilyContentPresenter" ContentTemplate="{StaticResource FamilyDataTemplate}" Visibility="{Binding ViewFamily}" />

                       <ContentPresenter x:Name="PatientContentPresenter" ContentTemplate="{StaticResource PatientDataTemplate}" Visibility="{Binding ViewPatient}" />

                   </Grid>

               </DataTemplate>       

            </TabControl.ContentTemplate>

        </TabControl>

ViewModel:

publicvoid ViewButtonClick(String buttonClicked, String value)

        {

           Debug.WriteLine("CallContainerViewModel - ViewButtonClick (buttonClicked/value): "+ buttonClicked +"/"+ value);

           //Close all, then open the one we actually want below

            ViewPatient =Visibility.Collapsed;

            ViewFamily =Visibility.Collapsed;

 

           if (buttonClicked.Equals("PatientButtonClick"))

            {

                ViewPatient =Visibility.Visible;

            }

           elseif (buttonClicked.Equals("FamilyButtonClick"))

            {

                ViewFamily =Visibility.Visible;

            }

 //I thought maybe "raising" the ContentPresenters might help...it didn't

            RaisePropertyChanged("PatientContentPresenter");

            RaisePropertyChanged("FamilyContentPresenter");

        }

   

privateVisibility viewPatient;

       publicVisibility ViewPatient

        {

           get {return ViewPatient; }

           set

            {

               Debug.WriteLine("CallContainerViewModel - ViewPatient:"+ value);

                viewPatient =value;

                RaisePropertyChanged("ViewPatient"); //FINALLY, THIS SHOULD REFRESH THE SCREEN WITH THE SELECTED TEMPLATE

            }

        }

 

       privateVisibility viewFamily;

       publicVisibility ViewFamily

        {

           get {return ViewFamily; }

           set

            {

               Debug.WriteLine("CallContainerViewModel - ViewFamily:"+ value);

                viewFamily =value;

                RaisePropertyChanged("ViewFamily");//FINALLY, THIS SHOULD REFRESH THE SCREEN WITH THE SELECTED TEMPLATE

            }

        }

This is the debug statements at run-time, and the values are what I'd expect:

CallContainerViewModel - ViewButtonClick (buttonClicked/value): FamilyButtonClick/Visible

CallContainerViewModel - ViewPatient: Collapsed

CallContainerViewModel - ViewFamily: Collapsed

CallContainerViewModel - ViewFamily: Visible

...so the ContentPresenters get collapased/visible get set properly, or so it seems, and theRaisePropertyChanged is called for both of them, but the tab (and the screen) does not refresh to show the selected ContentPresenter. Strangely enough, when the screen initially loads, the second ContentPresenter inside the Grid is open and showing, even though I did not specify that...but pressing the buttons to make the one I want appear does not work.

If anyone can fix what I'm doing wrong (with the corrected code in their answer), I'd be eternally grateful !

Barry

P.S. I just noticed that the "<DataTemplate>" within the TabControl XAML may be redundant as the value is supposed to be bound to the <DataTemplate> definitions within the Window.Resources section...

P.S.S. If someone wants to suggest an alternate approach, then please include all the required code in the response...but I'd prefer to just make what I already have work :-) thanx again !


Barry O'Neill

.NET 4.5 CRITICAL -- SelectedItem not setting Binding item.

$
0
0

I'll hope this is a known issue, but...

I was looking to upgrade from Visual Studio 2010 to 2012, and began testing it out.  Immediately, something went wrong with combo boxes.  ItDOES NOT UPDATE the Text or SelectedItem property when they are bound to our data object classes.  This happens with every combobox across our application.  One example is below.

<my:MyComboBox x:Name="my_select" Text="{Binding Instance.UserLoginInfo.SelectedNumber, Mode=TwoWay}" ItemsSource="{Binding Instance.Profile.PickList}" DisplayMemberPath="ItemName" HorizontalAlignment="Right" VerticalAlignment="Bottom" FontSize="21.333" Width="180" Margin="0,8,0,0"  />

About this code:

  • .NET 4.5 is installed, but the target build for the application is still ".NET Framework 4"
  • MyComboBox inherits directly from ComboBox.
  • The PickList comes from a local database.
  • I DO see the proper items list in the combobox.
  • When I override the OnSelectionChanged method, I do receive the call, but I still do not see the binding being updated.
  • The same, exact code, with no changes whatsoever, works on VS 2010/.NET 4.0.
  • I've even tried verifying (via GetHashCode) that the referenced objects are what they should be.

Now, before anyone asks, we've already done our due diligence with regard to this issue:

  • The data object class UserLoginInfo implements INotifyPropertyChanged.  Again, it works with VS 2010/.NET 4.0 with no changes.
  • The binding path is correct.  Again, it works with VS 2010/.NET 4.0 with no changes.
  • If I change the inheritance from ComboBox to a third-party dropdown (specifically ComponentOne's C1ComboBox), it works.

If there is any guidance to offer regarding this issue, I'd be very happy to hear it.



Using mouse events to drag control

$
0
0

I have a set of items on a canvas that I want to be able to drag around using the mouse.  I have it working with events with one exception.  The events that I am using are MouseMove, MouseLeftButtonDown, and MouseLeftButtonUp.  If I have two controls that I could drag, when I drag one of them over the other everything works as expected.  When I drag the other one over the first then it gets caught at  the edge of the first one.  I assume this has something to do with Z Index.

My MouseMove handler looks something like this with start being initialized in mouse down and x.X and x.Y being bound to the bottom left corner:

private void Grid_MouseMove_1(object sender, MouseEventArgs e)
{
   if (e.LeftButton == MouseButtonState.Pressed && s == sender)
   {
      var presenter = (Grid)sender;
      dynamic x = presenter.DataContext;
      var position = e.GetPosition(Display);
      var delta = position - start;
      start = position;
      x.X += delta.X;
      x.Y -= delta.Y;
   }
}
Any ideas on how I would make this work for all cases?

How do I apply a trigger to the content of a group header?

$
0
0

I have an simple app I'm using to test things out in, before incorporating what I've learned from there into a larger app. Initially I had a single listbox with a ItemTemplate, and within that I defined a DataTemplate with a DataTemplate.Triggers for conditionally display the generation of a person (e.g.: "Jr." or "III"). Now I'm trying to change this so that the listbox will have a GroupStyle. Within the GroupStyle I redefine the GroupItem and set it with a custom template.  That custom template has a grid with 2 rows, one for the header and the other for the rest of the content (which is in an ItemsPresenter control). The header in the first row of the grid has a textblock, data bound to the Generation field in our database. If it was null, then the textblock isn't shown; it is otherwise.

This worked fine when it was just a simple listbox, listing each item, but if I use groups, then I'm stuck as to how to apply the DataTemplate.Triggers to the header row of the grid, that had been been applied to each item in the listbox. (I do hope that I'm clear.) How do I do what I'm asking for, please?


Rod

Make ViewModels activation aware in Prism/Composite application

$
0
0

I'm using Unity and Prism EventAggregator in my MVVMC application I have a process which contains multiple steps, basically a wizard.

My controller resolves my outer View (call it WizardView) and adds it to the main region.

WizardView contains a breadcrumb trail to show the progress through the wizard and a sub Region to load other views into (call this WizardRegion). Step1View is the first View loaded intoWizardRegion.

Each view has it's ViewModel injected into the constructor using the Unity container.

WizardViewModel subscribes to several event aggregation events which are published by the step view models.

As each step is completed the View Model publishes an event which WizardViewModel uses to store the state, this means WizardViewModel is collecting the data from each step as we progress. The step ViewModel also calls the controller to load the next step into WizardRegion.

At the final step WizardViewModel saves the result of the wizard and the MainRegion is navigated back to some other screen.

The next time we enter the wizard, we create a new instance of all the Views and ViewModels but the event subscriptions from the previous wizard still exist.

I've confirmed that I'm using weak events by passing false to the Subscribe method but I suspect that because they're not garbage collected the event is sill being handled. How can I make my  ViewModels activation aware? I'm sure I've seen a link somewhere but cant find it again now.

Thanks

Ben

How to send a Window object from an STA thread back to the UI Thread????

$
0
0

Hello,

I am creating a WPF Window splash window to display progress for an application startup.  The window calls a Thread class which is set to an STA thread so that the thread can instantiate the main application window (ex. MainWindow win = new MainWindow()) and then run various methods to gather some initial data.  The window will not be displayed here though.  All is well up until I need to get the instantiated "win" object from the thread and back to the splash UI thread.  I am getting the typical "object can't be used because it was created in a different thread" message.  I tried various things regarding a dispatcher, such as:

splash.Dispatcher.BeginInvoke(InitAppTaskComplete, new object[] { win });

The method from my splash class that gets the invoke callback gets a good Window object but if it tries to show it, I still gets the error that it was created in another thread.  I have been trying countless avenues in trying to solve this (using background workers, Task delegates, etc) but I always either run into either the issue of it being created in another thread or an error that the current thread must be an STA thread to instantiate the Window object. Does anyone have any thoughts on how I might be able to accomplish this?

Thanks - Peter

how to focus control to AutoCompleteBox

$
0
0
How to focus the keyboard control to AutoCompleteBox auto_name i used auto_name.focus(),this is not working. any other methods available for that..??

Wpf remove Constraint from datatable

$
0
0

I have datatable created from MS Access database using DataAdapter.
for ex: adapter.Fill(result);

Issue is, MS Access datatable has Primary key. But i dont want to have that
primary key Constraint to my new datatable.

I tried below code to remove constraint but it's not working:

foreach (Constraint cnst in result.Constraints)
   {
      if (result.Constraints.CanRemove(cnst)) // it always returns false.
      {
         result.Constraints.Remove(cnst);
      }
   }

Error: Cannot remove unique constraint since it's the primary key of table Copy of Table1.

Please help me how would I delete constraint.

Thanks
Dee

WPF control binding to an observable collection - give me my Prozak

$
0
0

God must have been off work when the binding system came to be. How can it be so very hard to get it to work? In pure frustration i googled "f**k wpf binding" and got well over a million hits.

All I want to do is display a few items in a list - in VB6 days i would have been done with all the spaghetti controlling adding and removing by now.

I had a working model up and running but decided to go from a listview to a datagridview instead. Made a few (small?) changes and kabam - im back to "nothing works" again. I get ArgumentNullExceptions, empty datagrid and a bunch of grey hairs on my head.

Tried to go back to listview but now that wont work either. I have not made any code changes to the code-behind so I'm pretty sure that part is OK.

Okay, here goes the code - now i'm switching to de-caff and taking my Prozac double time:

(and thank you guys for reading my rants :) )

<Window x:Class="winSessions"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:MyApp_2013"
    Title="winSessions" Height="300" Width="506"><Window.Resources><!--<local:CoolItemsCollectionClass x:Key="students"/>--></Window.Resources><Grid x:Name="LayoutRoot"><Grid.RowDefinitions><RowDefinition Height="32" /><RowDefinition /></Grid.RowDefinitions><Label FontFamily="Arial" FontSize="22" FontWeight="Bold" FontStyle="Italic" Foreground="White" Background="LightSteelBlue">Sessions stored in unit memory</Label><Border Grid.Row="1" BorderThickness="12"><DataGrid 
                Name="lvwSessions"     
                    AutoGenerateColumns="False" 
                    ItemsSource="{Binding}" 
                    CanUserResizeColumns="True" 
                    CanUserReorderColumns="True" 
                    CanUserSortColumns="True" 
                    AlternatingRowBackground="Gainsboro"  
                    AlternationCount="2" 
                    FrozenColumnCount="1"><DataGrid.Columns><DataGridTextColumn Binding="{Binding Path=Index}" Header="Index"/><DataGridTextColumn Binding="{Binding Path=Filename}" Header="Filename"/><DataGridTextColumn Binding="{Binding Path=Size}" Header="Size"/><DataGridTextColumn Binding="{Binding Path=Guid}" Header="Guid"/></DataGrid.Columns><!--<DataGrid.RowDetailsTemplate><DataTemplate><TextBlock Text="{Binding Filename}" FontSize="13" Foreground="White" Background="#FF3F618D"/></DataTemplate></DataGrid.RowDetailsTemplate>--></DataGrid><!--<ListView HorizontalAlignment="Stretch" Name="lvwSessions" VerticalAlignment="Stretch" ItemsSource="{Binding}" IsSynchronizedWithCurrentItem="True"><GridView.ColumnCollection><GridViewColumn Width="40" Header="Index" DisplayMemberBinding="{Binding Path=Index}" /><GridViewColumn Width="140" Header="Filename" DisplayMemberBinding="{Binding Path=Filename}" /><GridViewColumn Width="60" Header="Size" DisplayMemberBinding="{Binding Path=Size}" /><GridViewColumn Width="140" Header="Guid" DisplayMemberBinding="{Binding Path=Guid}" /></GridView.ColumnCollection></ListView>--></Border><!--</ScrollViewer>--></Grid></Window>

Option Strict On
Option Explicit On
Imports System.Collections.ObjectModel
Imports System.ComponentModel

Public Class winSessions
    Private _fh As clsFilehandler
    Dim ObservableCoolItemsCollection As CoolItemsCollectionClass

    Dim aView As ICollectionView

    Public Sub New()

        ' This call is required by the designer.
        InitializeComponent()

        ' Add any initialization after the InitializeComponent() call.
        ObservableCoolItemsCollection = CType(Me.Resources("ObservableCoolItemsCollection"), CoolItemsCollectionClass)
        aView = CollectionViewSource.GetDefaultView(ObservableCoolItemsCollection)
    End Sub

    Public Sub Init(ByRef Filehandler As clsFilehandler)
        _fh = Filehandler
        ObservableCoolItemsCollection = New CoolItemsCollectionClass
        '_ft = CType(Me.Resources("_ft"), clsFileTable)
        aView = CollectionViewSource.GetDefaultView(ObservableCoolItemsCollection)

        For i As Integer = 0 To Filehandler.Count
            ObservableCoolItemsCollection.Add(Filehandler.Entry(i))
        Next
        'lvwSessions.DataContext = ObservableCoolItemsCollection
        'ObservableCoolItemsCollection = CType(Me.Resources("ObservableCoolItemsCollection"), CoolItemsCollectionClass)
        Me.DataContext = ObservableCoolItemsCollection

    End Sub
End Class

Public Class CoolItemsCollectionClass
    Inherits System.Collections.ObjectModel.ObservableCollection(Of clsUnitFile)
    Public Sub New()
        'Me.Add(New clsUnitFile(Guid.NewGuid, "Testentry", 24, 0))
    End Sub
End Class


combobox - get mouse events to template items

$
0
0
I have a combobox with an itemtemplate. I want to show tooltips for individual elements in the itemtemplate. I want to show them for the selecteditem while the combobox dropdown is not shown. I think the combobox is not allowing mouse events to get through to the itemtemplate elements. Is there a way to make the combobox ignore mouse events that occur over the selecteditem itemtemplate?

Bill Swartz


"System.Windows" causing Memory Leaks in WPF Application

$
0
0

Hi,

We are having custom message box control which is derived from Window. 

We have observed that after closing the dialog also the particular view is still in memory.

We have couple of Views where we have used using System.Windows;using System.Windows.Input; references, after closing the particular view(UI) that remains in memory and causing memory leaks. 

what we need to do in this case, please suggest.

Thanks,

Ajit

How to avoid Out of Memory exception in WPF application?

$
0
0

Hi,

We have very complex WPF application. Where user can open 20 tabs at a time with thousand of rows. Each tab contains three grid and all can be contains thousands of rows. We have observed that if user open 8-10 tabs containing huge data Application trows out of memory exception. (I am using Windows 7 32 bits with 4 GB RAM). This happens when memory goes beyond 1.2 GB.

I want to provide notification to the user if application reach 1 GB of threshold value. So that user can save important data and close some tabs to release the memory.

I wanted to know possible way to implement this case. I am thinking to use "memoryfailpoint", but not able to figure out when i can place this. 

Let me know your view on the same.

Thanks,

Ajit

Embedded fonts in styles at runtime

$
0
0

This is kind of a re-post, and I apologize for that, but in doing a repro, I realized I hadn't described the problem accurately, and I only got one (well-meant, but irrelevant) response to my original. And not finding a solution to this will be a very.bad.thing...

So, the problem is that when I have two stylesheets, one that defines the styles, and second that sets them as implicit, the embedded font is displayed correctly in the designer, but not at runtime.

Steps to Repro:

  1. Add an embedded font to your project (I used BuxtonSketch)
  2. Create a basic ResourceDictionary file (mine is called PoCDefaults.xaml) that declares the font as a resource and contains a style that references the resource:

    <SolidColorBrush x:Key="BaseForeground-Sketch" Color="#FF606060"/>
    <FontFamily x:Key="FontFamily-Sketch">Fonts/#Buxton Sketch</FontFamily>

    <!-- Basic Sketch TextBlock -->
    <Style x:Key="TextBlock-PoC" TargetType="{x:Type TextBlock}">
    <Setter Property="FontFamily" Value="{DynamicResource FontFamily-Sketch}"/>
    <Setter Property="FontSize" Value="16"/>
    <Setter Property="Foreground" Value="{DynamicResource BaseForeground-Sketch}"/> </Style>
  3. Add a second ResourceDictionary that sets the TextBlock-PoC as the default for TextBlock controls:

    <Style TargetType="{x:Type TextBlock}" BasedOn="{Static Resource TextBlock-PoC}" />
  4. Reference both files in a MergedDictionary in App.xaml.
  5. Add a TextBlock to MainWindow. It displays correctly in the designer:

But not at runtime:



Rebecca M. Riordan

create templates in a customcontrol, which are accessbile from xaml

$
0
0

hey,

i temporaly create a CustomControl in which i Need to create Templates like CellTemplates or HeaderTemplates, which i wanna be create accessbile from Xaml, i f a user implement the CustomControl.

How can i do this???

Is there a WPF equivalent for WindowsFormsApplicationBase?

$
0
0

Is there any class in WPF that would allow me to handle a splashscreen with text changing, as well as the argument acceptation, even in the case of a second launch that result in the same single application instance ? Though this class was in Microsoft.VisualBasic, it was possible to use it in C#, and that was very practical. Is there anything equivalent in WPF, and if not, what would you recommand for these two needs (changing splash, and single instance with arguments management) ?

Thanks in advance for any hints.

Viewing all 18858 articles
Browse latest View live


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