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

System.OutOfMemoryException: Insufficient memory to continue the execution of the program.

$
0
0

Hi all,

I have developed a WPF application with two microsoft datagrid. I have added hockey app (third party application) to my application to identify silent crashes. So, from hockey app, I am getting an OutOfMemory exception states that;

System.Windows.Media.Composition.DUCE.Channel.CreateOrAddRefOnChannel
Reason: System.OutOfMemoryException: Insufficient memory to continue the execution of the program.

It occurs almost 29543 times. I really don't have any knowledge to fix this.

So please help me get out of it.. 

I think each and every cell of the datagrid throws an exception, here the stack trace as follows;

System.OutOfMemoryException: Insufficient memory to continue the execution of the program.
   at System.Windows.Media.Composition.DUCE.Channel.CreateOrAddRefOnChannel(Object instance, ResourceHandle& handle, ResourceType resourceType)
   at System.Windows.Media.RenderData.System.Windows.Media.Composition.DUCE.IResource.AddRefOnChannel(Channel channel)
   at System.Windows.UIElement.RenderContent(RenderContext ctx, Boolean isOnChannel)
   at System.Windows.Media.Visual.RenderRecursive(RenderContext ctx)
   at System.Windows.Media.Visual.UpdateChildren(RenderContext ctx, ResourceHandle handle)
   at System.Windows.Media.Visual.RenderRecursive(RenderContext ctx)
   at System.Windows.Media.Visual.UpdateChildren(RenderContext ctx, ResourceHandle handle)
   at System.Windows.Media.Visual.RenderRecursive(RenderContext ctx)
   at System.Windows.Media.Visual.UpdateChildren(RenderContext ctx, ResourceHandle handle)
   at System.Windows.Media.Visual.RenderRecursive(RenderContext ctx)
   at System.Windows.Media.Visual.UpdateChildren(RenderContext ctx, ResourceHandle handle)
   at System.Windows.Media.Visual.RenderRecursive(RenderContext ctx)
   at System.Windows.Media.Visual.UpdateChildren(RenderContext ctx, ResourceHandle handle)
   at System.Windows.Media.Visual.RenderRecursive(RenderContext ctx)
   at System.Windows.Media.Visual.UpdateChildren(RenderContext ctx, ResourceHandle handle)
   at System.Windows.Media.Visual.RenderRecursive(RenderContext ctx)
   at System.Windows.Media.Visual.UpdateChildren(RenderContext ctx, ResourceHandle handle)
   at System.Windows.Media.Visual.RenderRecursive(RenderContext ctx)
   at System.Windows.Media.Visual.UpdateChildren(RenderContext ctx, ResourceHandle handle)
   at System.Windows.Media.Visual.RenderRecursive(RenderContext ctx)
   at System.Windows.Media.Visual.UpdateChildren(RenderContext ctx, ResourceHandle handle)
   at System.Windows.Media.Visual.RenderRecursive(RenderContext ctx)
   at System.Windows.Media.Visual.UpdateChildren(RenderContext ctx, ResourceHandle handle)
   at System.Windows.Media.Visual.RenderRecursive(RenderContext ctx)
   at System.Windows.Media.Visual.UpdateChildren(RenderContext ctx, ResourceHandle handle)
   at System.Windows.Media.Visual.RenderRecursive(RenderContext ctx)
   at System.Windows.Media.Visual.UpdateChildren(RenderContext ctx, ResourceHandle handle)
   at System.Windows.Media.Visual.RenderRecursive(RenderContext ctx)
   at System.Windows.Media.Visual.UpdateChildren(RenderContext ctx, ResourceHandle handle)
   at System.Windows.Media.Visual.RenderRecursive(RenderContext ctx)
   at System.Windows.Media.Visual.UpdateChildren(RenderContext ctx, ResourceHandle handle)
   at System.Windows.Media.Visual.RenderRecursive(RenderContext ctx)
   at System.Windows.Media.Visual.UpdateChildren(RenderContext ctx, ResourceHandle handle)
   at System.Windows.Media.Visual.RenderRecursive(RenderContext ctx)
   at System.Windows.Media.Visual.UpdateChildren(RenderContext ctx, ResourceHandle handle)
   at System.Windows.Media.Visual.RenderRecursive(RenderContext ctx)
   at System.Windows.Media.Visual.UpdateChildren(RenderContext ctx, ResourceHandle handle)
   at System.Windows.Media.Visual.RenderRecursive(RenderContext ctx)
   at System.Windows.Media.Visual.UpdateChildren(RenderContext ctx, ResourceHandle handle)
   at System.Windows.Media.Visual.RenderRecursive(RenderContext ctx)
   at System.Windows.Media.Visual.UpdateChildren(RenderContext ctx, ResourceHandle handle)
   at System.Windows.Media.Visual.RenderRecursive(RenderContext ctx)
   at System.Windows.Media.Visual.UpdateChildren(RenderContext ctx, ResourceHandle handle)
   at System.Windows.Media.Visual.RenderRecursive(RenderContext ctx)
   at System.Windows.Media.Visual.UpdateChildren(RenderContext ctx, ResourceHandle handle)
   at System.Windows.Media.Visual.RenderRecursive(RenderContext ctx)
   at System.Windows.Media.Visual.UpdateChildren(RenderContext ctx, ResourceHandle handle)
   at System.Windows.Media.Visual.RenderRecursive(RenderContext ctx)
   at System.Windows.Media.Visual.UpdateChildren(RenderContext ctx, ResourceHandle handle)
   at System.Windows.Media.Visual.RenderRecursive(RenderContext ctx)
   at System.Windows.Media.Visual.UpdateChildren(RenderContext ctx, ResourceHandle handle)
   at System.Windows.Media.Visual.RenderRecursive(RenderContext ctx)
   at System.Windows.Media.Visual.UpdateChildren(RenderContext ctx, ResourceHandle handle)
   at System.Windows.Media.Visual.RenderRecursive(RenderContext ctx)
   at System.Windows.Media.Visual.UpdateChildren(RenderContext ctx, ResourceHandle handle)
   at System.Windows.Media.Visual.RenderRecursive(RenderContext ctx)
   at System.Windows.Media.Visual.UpdateChildren(RenderContext ctx, ResourceHandle handle)
   at System.Windows.Media.Visual.RenderRecursive(RenderContext ctx)
   at System.Windows.Media.Visual.UpdateChildren(RenderContext ctx, ResourceHandle handle)
   at System.Windows.Media.Visual.RenderRecursive(RenderContext ctx)
   at System.Windows.Media.Visual.UpdateChildren(RenderContext ctx, ResourceHandle handle)
   at System.Windows.Media.Visual.RenderRecursive(RenderContext ctx)
   at System.Windows.Media.Visual.UpdateChildren(RenderContext ctx, ResourceHandle handle)
   at System.Windows.Media.Visual.RenderRecursive(RenderContext ctx)
   at System.Windows.Media.Visual.UpdateChildren(RenderContext ctx, ResourceHandle handle)
   at System.Windows.Media.Visual.RenderRecursive(RenderContext ctx)
   at System.Windows.Media.Visual.UpdateChildren(RenderContext ctx, ResourceHandle handle)
   at System.Windows.Media.Visual.RenderRecursive(RenderContext ctx)
   at System.Windows.Media.Visual.UpdateChildren(RenderContext ctx, ResourceHandle handle)
   at System.Windows.Media.Visual.RenderRecursive(RenderContext ctx)
   at System.Windows.Media.Visual.UpdateChildren(RenderContext ctx, ResourceHandle handle)
   at System.Windows.Media.Visual.RenderRecursive(RenderContext ctx)
   at System.Windows.Media.Visual.UpdateChildren(RenderContext ctx, ResourceHandle handle)
   at System.Windows.Media.Visual.RenderRecursive(RenderContext ctx)
   at System.Windows.Media.Visual.UpdateChildren(RenderContext ctx, ResourceHandle handle)
   at System.Windows.Media.Visual.RenderRecursive(RenderContext ctx)
   at System.Windows.Media.Visual.UpdateChildren(RenderContext ctx, ResourceHandle handle)
   at System.Windows.Media.Visual.RenderRecursive(RenderContext ctx)
   at System.Windows.Media.Visual.UpdateChildren(RenderContext ctx, ResourceHandle handle)
   at System.Windows.Media.Visual.RenderRecursive(RenderContext ctx)
   at System.Windows.Media.Visual.UpdateChildren(RenderContext ctx, ResourceHandle handle)
   at System.Windows.Media.Visual.RenderRecursive(RenderContext ctx)
   at System.Windows.Media.Visual.UpdateChildren(RenderContext ctx, ResourceHandle handle)
   at System.Windows.Media.Visual.RenderRecursive(RenderContext ctx)
   at System.Windows.Media.Visual.UpdateChildren(RenderContext ctx, ResourceHandle handle)
   at System.Windows.Media.Visual.RenderRecursive(RenderContext ctx)
   at System.Windows.Media.Visual.Render(RenderContext ctx, UInt32 childIndex)
   at System.Windows.Media.CompositionTarget.Compile(Channel channel)
   at System.Windows.Media.CompositionTarget.System.Windows.Media.ICompositionTarget.Render(Boolean inResize, Channel channel)
   at System.Windows.Media.MediaContext.Render(ICompositionTarget resizedCompositionTarget)
   at System.Windows.Media.MediaContext.RenderMessageHandlerCore(Object resizedCompositionTarget)
   at System.Windows.Media.MediaContext.RenderMessageHandler(Object resizedCompositionTarget)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)

So anybody please help me to get rid of it...... 

Thanks,
Hussain.

Also some forums explained to put microsoft datagrid into panel other than stackpanel. I already placed it in a Grid.


How to handle `ScrollViewer.ScrollChanged` event in MVVM?

$
0
0

I've tried to handle the routed event ScrollViewer.ScrollChanged of DataGrid in obvious way:

<i:Interaction.Triggers><i:EventTrigger EventName="ScrollViewer.ScrollChanged"><ei:CallMethodAction MethodName="ScrollChangedHandler" TargetObject="{Binding}"/></i:EventTrigger></i:Interaction.Triggers>

But ScrollChangedHandler did not even fired.

Then, I've found this article about handling events, but I could not figure out what xml namespace(xmlns) is used for mvvmjaco:

<Image Width="360" Height="177" Source="Resources\PlayerArea.png"><i:Interaction.Triggers><mvvmjoy:RoutedEventTrigger RoutedEvent="s:Contacts.ContactDown"><mvvmjaco:CommandAction Command="{Binding TouchCommand}" /></mvvmjoy:RoutedEventTrigger></i:Interaction.Triggers></Image>

mvvmjoy uses this class from the article:

public class RoutedEventTrigger :EventTriggerBase<DependencyObject>
{
    RoutedEvent _routedEvent;
    //The code omitted for the brevity
}

Basically, I have two questions:

  1. What class or library should I use for mvvmjaco xml namespace?
  2. How I can handle ScrollViewer.ScrollChanged event in my viewModel with its arguments?



ComboBox Dataset

$
0
0

Hallo!

I have a Dataset with Categories and Products. In Products I have column CategoriesID. Now I want show the data from the products in textboxes and instead the CategoriesID the CategoriesName in a ComboBox (like Master/Detail). Can You helb me to understand this? Sorry for my wrong english!!!

Squares instead of the Unicode text

$
0
0

Hello folks!

After we have upgraded to Windows 10 we received the error (Squares instead of Unicode text) below in our wpf application.

sIs it Windows related problem? Any advice would be most welcome!

Auto resizing my wpf window and report viewer

$
0
0

Hi all below is my xaml file for one of my windows.Currently I have been developing in this resolution 1440 * 900. All looks goods. The moment I change to a different resolution everything looks weird with my top portion of my window is missing where I need to few times click before it appears. What can I do to make it auto resize not only the window but also the report viewer. Currently everything is fixed as Height="850" Width="1080"

<

Controls:MetroWindow x:Class="WpfApplication1.Window7"        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"        xmlns:local="clr-namespace:WpfApplication1"        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:wfi="clr-namespace:System.Windows.Forms.Integration;assembly=WindowsFormsIntegration"        xmlns:rv="clr-namespace:Microsoft.Reporting.WinForms;assembly=Microsoft.ReportViewer.WinForms"        xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"        mc:Ignorable="d"        BorderThickness="2"                     GlowBrush="{DynamicResource AccentColorBrush}"                      ResizeMode="CanResizeWithGrip"                      WindowTransitionsEnabled="False"                      WindowStartupLocation="CenterScreen"        Title="Verification" Height="850" Width="1080">    <Controls:MetroContentControl>        <Grid>            <Grid.RowDefinitions>                <RowDefinition Height="35" />                <RowDefinition Height="50" />                <RowDefinition Height="50" />                <RowDefinition Height="*" />            </Grid.RowDefinitions>            <StackPanel Grid.Row="0"
Orientation="Horizontal">                <Menu DockPanel.Dock="Top">                    <MenuItem Header="_Reports">                        <MenuItem Header="_Ex01" Click="MenuItem_Click" Tag="1" />                    </MenuItem>                </Menu>            </StackPanel>            <StackPanel Grid.Row="1"
Orientation="Horizontal">            </StackPanel>            <StackPanel Grid.Row="2"
Orientation="Horizontal">                <StackPanel x:Name="_ribbonRadioButtonPanel" Orientation="Vertical" Grid.Column="0">                </StackPanel>                <StackPanel x:Name="_ribbonRadioButtonPanel2" Grid.Column="1">                </StackPanel>                          </StackPanel>            <StackPanel Grid.Row="3"
Orientation="Horizontal">                <WindowsFormsHost Width="977" Margin="50,32,0,0">                    <rv:ReportViewer x:Name="_reportViewer"/>                </WindowsFormsHost>            </StackPanel>        </Grid>    </Controls:MetroContentControl></Controls:MetroWindow>

TreeView selected node expand/collapse

$
0
0

Hi.

I have code bellow. I want after MouseRightButtonUp expand selected node and collapse other nodes. Can you help me?

Thanks.


<Window x:Class="WpfTreViewSubItem.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525"><Grid><TreeView MouseRightButtonUp="TreeView_MouseRightButtonUp" MouseRightButtonDown="TreeView_MouseRightButtonDown"  MouseDoubleClick="TreeView_MouseDoubleClick" ><TreeViewItem Header="Program" Tag= "0" FontSize="13" IsExpanded="True"/></TreeView></Grid></Window>

    private void TreeView_MouseRightButtonDown(object sender, MouseButtonEventArgs e)
        {
            TreeViewItem treeViewItem = VisualUpwardSearch(e.OriginalSource as DependencyObject);
            if (treeViewItem != null)
            {
                treeViewItem.Focus();
                e.Handled = true;
            }
        }
        static TreeViewItem VisualUpwardSearch(DependencyObject source)
        {
            while (source != null && !(source is TreeViewItem))
                source = VisualTreeHelper.GetParent(source);
            return source as TreeViewItem;
        }

ListBox does not select on the first click

$
0
0

Hi Guys,

I got two ListBoxes, ListBox1 and ListBox2.  Each one has a "SelectionChanged" handler in which there is a UnselectAll() function to unselect the other ListBox.

Under each ListBox, there is a TextBlock to show what is selected.

The selection does not fire on the first click (except the very first click), but it works afterwards.

For example, when you click the ListBox1 for the very first time, it works, the textBlock shows the index of whatever you select. However when you click on ListBox2, the selection does not fire at all (the TextBlock below keeps -1 ), but it fires on the second click and afterwards. When you go back to the ListBox1, it does the same thing.

Question:
1, why?
2, How to get the selection fires on the first click?
Thanks.

Richard

Here is the .xaml

<Window x:Class="WpfApplication1.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525"><Grid x:Name="grid"><ListBox x:Name="ListBox1" Height="142" Width="30" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="100,98,0,0" SelectionChanged="ListBox1_SelectionChanged" ><ListBoxItem Content="1"/><ListBoxItem Content="2"/><ListBoxItem Content="3"/><ListBoxItem Content="4"/><ListBoxItem Content="5"/><ListBoxItem Content="6"/></ListBox><ListBox x:Name="ListBox2" Height="142" Width="30" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="200,98,0,0" SelectionChanged="ListBox2_SelectionChanged" ><ListBoxItem Content="a"/><ListBoxItem Content="b"/><ListBoxItem Content="c"/><ListBoxItem Content="d"/><ListBoxItem Content="e"/><ListBoxItem Content="f"/></ListBox><TextBlock x:Name="tb1" HorizontalAlignment="Left" Height="25" Margin="85,259.8,0,0" TextWrapping="Wrap" Text="{Binding SelectedIndex, ElementName=ListBox1}" VerticalAlignment="Top" Width="65" Background="#FFB3C9D8"/><TextBlock x:Name="tb2" HorizontalAlignment="Left" Height="25" Margin="185,259.8,0,0" TextWrapping="Wrap" Text="{Binding SelectedIndex, ElementName=ListBox2}" VerticalAlignment="Top" Width="65" Foreground="#FF010101" Background="#FFB3C9D8"/></Grid></Window>

Here is the .cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace WpfApplication1
{
        public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }

        private void ListBox1_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
       {
		ListBox2.UnselectAll();
	}

        private void ListBox2_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
        {
	      ListBox1.UnselectAll();
        }
    }
}

Thanks


Rendering glitches while scrolling horizontally in DataGrid with grouping

$
0
0

Hello.

When I create a DataGrid (WPF4) with grouping and fill it with >200 rows I get rendering glitches during horizontal scrolling: when I scroll to the right and back to the left blank spaces appears on the left side corrupting cells' content. If I define a DataGroup.GroupStyle the bug surfaces. And if I don't the grid works just fine, 200 rows or 1000. 

Please tell me how to get rid of this bug. Is there any workaround? Any suggestions?

Even something like this is enough to reproduce the problem (cvsGoods is a CollectionViewSource with a single PropertyGroupDescription defined and with 200 rows):

<DataGridItemsSource="{Binding Source={StaticResource ResourceKey=cvsGoods}}"><DataGrid.GroupStyle><GroupStyle><GroupStyle.HeaderTemplate><DataTemplate><TextBlockText="{Binding Name}"/></DataTemplate></GroupStyle.HeaderTemplate></GroupStyle></DataGrid.GroupStyle></DataGrid>


Wavy line

$
0
0

Hello

I have a problem by drawing wavy lines with a brush.



My questions:

1) Why are the first three lines so different while they use the same brush?

2) What is needed that all lines look the same independently of their vertical coordinates?

Here the is the sample code:


<Window.Resources><VisualBrush x:Key="WavyBrush" Viewbox="0,0,3,2" ViewboxUnits="Absolute" Viewport="0,0.8,6,4" ViewportUnits="Absolute" TileMode="Tile"><VisualBrush.Visual><Path Data="M 0,1 C 1,0 2,2 3,1" Stroke="Red" StrokeThickness="0.2" StrokeEndLineCap="Square" StrokeStartLineCap="Square" /></VisualBrush.Visual></VisualBrush></Window.Resources><Canvas Width="300" Height="150"><Line X1="0" Y1="10" X2="300" Y2="10" Stroke="{StaticResource WavyBrush}" StrokeThickness="6"/><Line X1="0" Y1="20" X2="300" Y2="20" Stroke="{StaticResource WavyBrush}" StrokeThickness="6"/><Line X1="0" Y1="33" X2="300" Y2="33" Stroke="{StaticResource WavyBrush}" StrokeThickness="6"/><RichTextBox Width="300" Height="100" Margin="0,50,0,0"><FlowDocument><Paragraph>
                           Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.<Run Text="At vero eos et accusam et justo"><Run.TextDecorations><TextDecoration Location="Underline"><TextDecoration.Pen><Pen Brush="{StaticResource WavyBrush}" Thickness="6"/></TextDecoration.Pen></TextDecoration></Run.TextDecorations></Run>
                           duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet,
                           consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.
                           At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.</Paragraph></FlowDocument></RichTextBox></Canvas>



Thanks in advance

Christoph

Designer Error in Visual Studio 2015 when using custom behaviors

$
0
0

I am developing a WPF application targeting .net framework 4.6, and referencing the Blend assemblies, including System.Windows.Interactivity version 4.5

Whenever I add a custom behavior to a XAML element (such as a Grid) I get a markup error under the behavior tag and it says: The type 'MyBehavior' from assembly 'Try.Ui' is built with an older version of Blend SDK, and is not supported in Windows Presentation Framework 4 project. 

I am using the latest version of System.Windows.Interactivity (4.5) and the behavior MyBehavior inherits Behavior<T> from that assembly. The project runs properly and the behavior works in runtime, but in design time there is that error, and the designer shows the message "Invalid Markup - check the error list for more information".

ExtendedToolkit DatePicker Calendar FontSize

$
0
0

I am using the ExtendedToolkit for WPF C#. Specifically I am using the DateTimePicker, I have tried changing the font size for this element however it does not change the size of the attached calendar that you use to select the date; 

Is there a way to change it's FontSize in the ExtendedToolkit so it appears larger?

Use Multi binding for passwordbox and radiobutton

$
0
0

i want to use multibinding for button is enabled when textbox and passwordbox are not empty

Converter:

public class FormFilledConverter:IMultiValueConverter
    {
        public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
        {
            string addrs = values[0].ToString();
            string fullName = values[1].ToString();
            string cty = values[2].ToString();
            string pwd = values[3].ToString();
            string conpwd = values[4].ToString();
           bool rm = (bool)values[5];
            bool rf = (bool)values[6];
            bool isAnyChecked = rm || rf;

            return addrs.Length != 0 && isAnyChecked  && fullName.Length != 0 && cty.Length != 0 && pwd.Length != 0 && conpwd.Length != 0;
        }
        public object[] ConvertBack(object value, Type[] targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }

Admin.xaml

 <TextBox x:Name="txtAddress" Margin="0" FontFamily="Times New Roman" FontSize="14" FontStyle="Normal" FontWeight="Normal" Height="100"/>
<TextBox x:Name="txtFullName" Margin="0,1,0,0" FontFamily="Times New Roman" FontSize="14" FontStyle="Normal" FontWeight="Normal" Height="19"/>

<TextBox x:Name="txtCity"  Margin="0,1,0,0" FontFamily="Times New Roman" FontSize="14" FontStyle="Normal" FontWeight="Normal" Height="19"/>

<PasswordBox x:Name="Pwd" HorizontalAlignment="Left"
                    VerticalAlignment="Top" Grid.Column="3" Grid.Row="3" Width="137" Height="21" Margin="0" FontSize="14" />
 <PasswordBox x:Name="ConPwd" HorizontalAlignment="Left" VerticalAlignment="Top" Grid.Column="3" Grid.Row="5" Width="137" Height="19" FontWeight="Normal" FontFamily="Times New Roman" FontSize="14" Margin="0,1,0,0"/>
<RadioButton x:Name="rbtMale" Content="Male" Grid.Column="2" Grid.Row="1" FontFamily="Times New Roman" FontSize="14" FontStyle="Normal" Margin="0,0,113,0" Foreground="White"/>
<RadioButton x:Name="rbtFemale" FontStyle="Normal" FontFamily="Times New Roman" FontSize="14" Grid.Column="2" Margin="63,0,41,0" Grid.Row="1" Content="Female" Foreground="White"/>

<Button x:Name="btnAddAdmin" Style="{StaticResource ButtonStyleTemplate}" Grid.Column="3" Margin="5,0" Content="Add" FontFamily="TimesNewRoman">
                    <Button.IsEnabled>
                        <MultiBinding Converter="{StaticResource FormFilledConverter}">
                            <Binding Path="Text" ElementName="txtAddress"/>
                            <Binding Path="Text" ElementName="txtFullName"/>
                            <Binding Path="Text" ElementName="txtCity"/>
                            <Binding Path="Password" ElementName="Pwd"/>
                            <Binding Path="Password" ElementName="ConPwd"/>

                            <Binding Path="IsChecked" ElementName="rbtMale"/>
                            <Binding Path="IsChecked" ElementName="rbtFemale"/>                                          </MultiBinding>
                    </Button.IsEnabled>
                </Button>

























WPF Command on Exnter Key press

$
0
0

Hi All,

I need to execute a command on key press enter so that whenever a user presses enter key on view after selecting any input from any dropdown or entering any text in  any textbox, it should execute that command on view and refreshes the Datagrid. I have that command in VM.
I have already that command present in ViewModel. Only I need to bind that command in View at one place not at each and every control so that this command gets executed for every control. So please help in implementing this asap.

Thanks

Pratham

Running custom animations in VisualStateManager

$
0
0

I have found a strange situation. When a VisualState has a custom-defined animation, it is not really using it.

The link to the project: https://dl.dropboxusercontent.com/u/2230946/VisualStateManagerTest.zip

What I did is:

* Created a custom animation ValueAnimation with a public class property IsEnabled. If it is, the animation just copies DoubleAnimation, if not - proviedes the destination value.

* Created a rectangle (Border), which state depends on the input number

When changing the number, the size is always animated, regardless of the IsEnabled flag. Moreover, a breakpoint placed in GetCurrentValueCore is never triggered. Instead, if one goes deeper with a debugger, it can be seen that a DoubleAnimation is executed instead - with THE SAME NAME as the assigned ValueAnimation! Like all properties from ValueAnimation were copied to a new DoubleAnimation - but not the functionality. Magic?


Mikhail

Wpf application stopped working on a different machine

$
0
0

Hi all,

       I am testing out a my wpf application on a different machine. My app settings is this

    <startup> 
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
    </startup>

Initially I installed 4.6 it did not work. Then I revert to 4.0 also its same symptom. Below is what I managed to capture 

 Problem signature:
  Problem Event Name:CLR20r3
  Problem Signature 01:wpfapplication1.exe
  Problem Signature 02:1.0.0.0
  Problem Signature 03:566fd297
  Problem Signature 04:mscorlib
  Problem Signature 05:4.0.0.0
  Problem Signature 06:4ba1da6f
  Problem Signature 07:2463
  Problem Signature 08:0
  Problem Signature 09:System.Windows.Markup.XamlParse
  OS Version:6.1.7601.2.1.0.256.48
  Locale ID:1033
  Additional Information 1:0a9e
  Additional Information 2:0a9e372d3b4ad19135b953a78882e789
  Additional Information 3:0a9e
  Additional Information 4:0a9e372d3b4ad19135b953a78882e789

Read our privacy statement online:
  http://go.microsoft.com/fwlink/?linkid=104288&clcid=0x0409

If the online privacy statement is not available, please read our privacy statement offline:
  C:\Windows\system32\en-US\erofflps.txt


WPF DataGrid Element Justify Right!?

$
0
0

Hi!
I have a DataGrid with some Colums...

Now I need die Column "Menge" with TextAlignment right...

Have anyone an idea how it can work?

<DataGrid.Columns ><DataGridTextColumn Header="BS" MinWidth="50" MaxWidth="50"  CanUserSort="True" Binding="{Binding GrSpalte01}" x:Name="SP001" IsReadOnly="True"/><DataGridTextColumn Header="Datum" MinWidth="80" MaxWidth="80" CanUserSort="True" Binding="{Binding GrSpalte02}" x:Name="SP002" IsReadOnly="True" /><DataGridTextColumn Header="Paletten-Platz" MinWidth="100" MaxWidth="150" CanUserSort="True" Binding="{Binding GrSpalte03}" x:Name="SP003" IsReadOnly="True" /><DataGridTextColumn Header="Menge" MinWidth="100" MaxWidth="150" CanUserSort="True" Binding="{Binding GrSpalte04}" x:Name="SP004" IsReadOnly="True" /><DataGridTextColumn Header="Buchungsart" MinWidth="150" MaxWidth="250" CanUserSort="True" Binding="{Binding GrSpalte05}" x:Name="SP005" IsReadOnly="True" /><DataGridTextColumn Header="Bemerkung zur Buchung" MinWidth="150" MaxWidth="250" CanUserSort="True" Binding="{Binding GrSpalte06}" x:Name="SP006" IsReadOnly="True" /><DataGridTextColumn Header="Artikel-Nr. / –Bezeichnung" MinWidth="200" MaxWidth="200" CanUserSort="True" Binding="{Binding GrSpalte07}" x:Name="SP007" IsReadOnly="True" /><DataGridTextColumn Header="Artikel-Nr. des Kunden" MinWidth="180" MaxWidth="180" CanUserSort="True" Binding="{Binding GrSpalte08}" x:Name="SP008" IsReadOnly="True" /><DataGridTextColumn Header="Gebucht von" MinWidth="100" MaxWidth="100" CanUserSort="True" Binding="{Binding GrSpalte09}" x:Name="SP009" IsReadOnly="True"/></DataGrid.Columns>

Best Regards

Bernd

How change binding to parent?

$
0
0

<UserControl x:Class="Sandogh.View.ModifiyMembersView"...><UserControl.DataContext><ViewModel:ModifyMembersViewModel /></UserControl.DataContext><ListView ItemsSource="{Binding Members}"><ListView.View><GridView><GridViewColumn><GridViewColumn.CellTemplate><DataTemplate><TextBox Text="{Binding FirstName}" /></DataTemplate></GridViewColumn.CellTemplate></GridViewColumn><GridViewColumn><GridViewColumn.CellTemplate><DataTemplate><TextBox Text="{Binding Message}" />  <!- this binding not work because is not part of Members, How access to message?--></DataTemplate></GridViewColumn.CellTemplate></GridViewColumn></GridView></ListView.View></ListView><!-- etc --></UserControl>


public class ModifyMembersViewModel
{
     //some code

        public IList<Member> Members
        {
            get { return _members; }
            private set
            {
                _members = value;
                RaisedPropertyChanged("Members");
            }
        }

        public string Message
        {
            get { return "Hi"; }
        }

     //Other Code
}


My Question Commented in bold style.
thanks.






WPF Using Multiple Threads to Display Loading Message

$
0
0

I've posted a similar question before, however now I am tailoring this question to a specific approach that I have decided to go with.

Simply put what I am trying to do is display a loading message after the user clicks on one page, that dissapears when the next page is fully loaded (loading 27000 companies into a DataGrid) and then the next page is displayed. The order looks like this;

  1. User clicks on button on first page
  2. "Please Wait...." is displayed on the same page whilst the next page is loading
  3. Next page is fully loaded
  4. Hide "Please Wait...."
  5. Display next page

What was recommended to me was using async and wait. This however froze my UI and would not work (Additional information: The calling thread cannot access this object because a different thread owns it.). I then started looking at using multiple threads which can hopefully solve my problem. This is what I have attempted so far;

The user has clicked the button to this page

public CompanyManagement()
        {
            InitializeComponent();
            Thread thread = Thread.CurrentThread;
            this.DataContext = new
            {
                ThreadId = thread.ManagedThreadId
            };
        }

The Page's Loaded event is called;

        private void PageLoaded(object sender, RoutedEventArgs e)
        {
            Thread thread = new Thread(() =>
            {
                var wait = new PleaseWait("My title", "My Message", () => FillDataGrid());
                wait.ShowDialog();
                System.Windows.Threading.Dispatcher.Run();
            });

            thread.SetApartmentState(ApartmentState.STA);
            thread.Start();
        }

FillDataGrid() is the method that takes all the time (retrieves the companies over OleDB), and looks like this;

        private void FillDataGrid()
        {
            var _cDS = new CompanyDataService();
            var Companies = new ObservableCollection<CompanyModel>();
            Companies = _cDS.HandleCompanySelect();
            CompanyICollectionView = CollectionViewSource.GetDefaultView(Companies);
            //CompanyICollectionView.SortDescriptions.Add(new SortDescription("CompanyName", ListSortDirection.Ascending));
            DataContext = this;
            cancelButton.Visibility = Visibility.Hidden;

            if (compNameRad.IsChecked == false &&
                compTownRad.IsChecked == false &&
                compPcodeRad.IsChecked == false)
            {
                searchBox.IsEnabled = false;
            }
            dataGrid.SelectedIndex = 0;
            SetDefaultFilter();
        }

This almost works in that the next page is loaded, the "Please Wait...." is displayed however I then get the error: The calling thread cannot access this object because a different thread owns it. Am I using the thread functionality incorrectly?

EDIT: I should show PleaseWaittoo!

public partial class PleaseWait : Window
    {
        readonly Action _action;
        public PleaseWait(string title, string message, Action action)
        {
            _action = action;
            InitializeComponent();
            this.Title = title;
            this.label.Content = message;
        }

        private async void loaded(object sender, RoutedEventArgs e)
        {
            await Task.Run(() => _action());
            this.Close();
        }
    }

Deriving from Shape and making Canvas.GetLeft work properly

$
0
0

 

Following Charles Petzold's answer to an earlier question, I derived my own class from Shape (starting from his nice arrowheads, described at http://www.charlespetzold.com/blog/2007/04/191200.html).  I then added an instance of my class to a Canvas, and tried to write code to make it draggable. I found some code, which relied on the thing being a UIElement (it is, because it's derived from Shape), and from it correctly providing results when Canvas.GetLeft and Canvas.GetTop were called. It did not in fact do that correctly.

 

So I went back to Charles's code, and check whether his arrows did so. After he instantiates the first arrow and Adds it to his Canvas, I added this:

Code Block

Debug

.Print("Left, Top = " + Canvas.GetLeft(aline1) + ", " + Canvas.GetTop(aline1));

Debug.Print("Bot, Right = " + Canvas.GetBottom(aline1) + ", " + Canvas.GetRight(aline1));

 

 

The result? Four NaNs.

 

I had figured that once I wrote a "DefiningGeometry" method, the Shape class would somehow use that to make all the Left, Right, Top and Bottom stuff work. It obviously doesn't. Can someone tell me how to make  Shape class that behaves more or less like other shapes (like, say, Ellipse) in this regard?

 

Thanks in advance.

 

-John

 

How to get last inserted id in C# using mySql (MsAccess)?

$
0
0

Hi all,

I tried lot of different possibilities of how to solve this problem but without success. How can I get last inserted id? My Code id there ... so what should I edit in this ...

string myQuery = "INSERT INTO Cars (type) VALUES('Peugeot');  SELECT SCOPE_IDENTITY()";
con.Close();
con.Open();
cmd.CommandText = myQuery;

Int32 newId = (Int32)cmd.ExecuteScalar();
MessageBox.Show( "Last ID : "+newId.ToString() );

cmd.ExecuteNonQuery();
cmd.Clone();
MessageBox.Show("Data saved!");
con.Close();
... this doesn't work

Viewing all 18858 articles
Browse latest View live


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