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

Error When Binding to a Dataset Datatable

$
0
0

I have a simple (no relations to other tables) table in my dataset.  I am building a wpf window for inputting new data.  All the input controls on the window are bound to the corresponding field in the datatable.  When the window loads I set the data context to a new row as follows:

Private Sub Expenses_Loaded(sender As Object, e As RoutedEventArgs) Handles Expenses.Loaded
DataContext = myApp.Tables("Expenses").NewRow
Expenses.Height = 380

which generates this error:

System.InvalidCastException was unhandled by user code
HResult=-2147467262
Message=Conversion from type 'DBNull' to type 'Long' is not valid.
Source=Microsoft.VisualBasic
StackTrace:
       at Microsoft.VisualBasic.CompilerServices.Conversions.ToLong(Object Value)
       at myApp.amAppDataSet.ExpensesRow.get_CategoryID() in F:\myApp\myAppDataSet.Designer.vb:line 2289

The line of code that creates the error is:

Return CType(Me(Me.tableExpenses.CategoryIDColumn),Long)
CategoryID as Long is one of the fields in the datatable.  This line of code is generated by VB as code behind the dataset.


Obviously, what is happening is that the new row contains Null values, which causes the error when the dataset tries to convert the null to a Long.  I've tried using a blocking converter and setting the Mode of the binding to OneWayToSource to no avail.

I have two questions:
1) How to avoid this error
2) Why does the error only occur when I resize the window


WPF Mainwindow is not Responding

$
0
0

Hello there, i have a problem regarding my wpf app,when i run it,it open Mainwindow,and the problem is that it d'not allow me to click anywhere on output window.when i minimize it from taskbar and then maximized,it works fine.

please help me .. as soon as possible.

Thanks in advance.


Om Prakash

Want to show HTML in RichTextBox

$
0
0

Hello ,

I want to show HTML string as HTML in RichTextBox . So say <b> Hello </b>  should display Hello asHello and similarly <a> tag should display text as clickable link . 

Please let me know is this is possible . I am new to WPF and try figure this one out .

Thanks


Kapil Gupta

Value cannot be null.Parameter name: source

$
0
0

I have created observation collection property. As below

  private ObservableCollectionEx<ATS> _atsCollection;
        public ObservableCollectionEx<ATS> ATSCollection
        {
            get { return _atsCollection; }
            set{
                _atsCollection = value;
                RaisePropertyChanged("ATSCollection");
            }
        }
And using in this method as;


 private void BindAtsData(int selectedNumber)
        {
            try
            {
                List<ATS> atsCollectionList=new List<ATS>();
                atsCollectionList = ATSCollection.ToList();
            }
            catch (Exception ex)
            {
                customerAC.LogFile(ex.ToString());
            }
        }

And we are getting error :"Value cannot be null.Parameter name: source"

How to fix this and how to internalize ATSCollection?


How to close all the background procees when we closing the wpf application.

$
0
0

We are running several background process in wpf application. We want to close all background process when we close the application.Currently when we close the application then application does not close completely and exe is showing in the task manager and visual studio raising the error.

We are running several process and we have no idea which process have been completed and which are not. But we want to close all the process with application.

How to fix this in wpf?




Calling all WPF Gurus. November readers need feeding!

$
0
0

An influential teacher, or popular expert

Oh mighty reader, we need your enlightenment! Only YOU can show us… the TRUE WAY to code!

Win the dedication and adoration of generations to come, by giving something back to those less awesome.

Show your technical prowess, and divine knowledge of your craft.

Teach us good code from bad. Show us the way (or the work-around)

We can offer you the very best platform that you need to preach these good words.

Join us and lead this technical community in a whole new way, into a brighter future!

Become a TechNet Guru and you may find your own life also significantly enriched!

Win awards, interviews, invites, reviews, medals, friends, recognition points, high fives, hugs, smiles, and so much more!

All you have to do is add an article to TechNet Wiki from your own specialist field. Something that fits into one of the categories listed on the submissions page. Copy in your own blog posts, a forum solution, a white paper, or just something you had to solve for your own day’s work today.

Drop us some nifty knowledge, or superb snippets, and become MICROSOFT TECHNOLOGY GURU OF THE MONTH!

This is an official Microsoft TechNet recognition, where people such as yourselves can truly get noticed!

HOW TO WIN

1) Please copy over your Microsoft technical solutions and revelations to TechNet Wiki.

2) Add a link to it on THIS WIKI COMPETITION PAGE (so we know you’ve contributed)

3) Every month, we will highlight your contributions, and select a “Guru of the Month” in each technology.

If you win, we will sing your praises in blogs and forums, similar to the weekly contributor awards. Once “on our radar” and making your mark, you will probably be interviewed for your greatness, and maybe eventually even invited into other inner TechNet/MSDN circles!

Winning this award in your favoured technology will help us learn the active members in each community.

Feel free to ask any questions below.

More about TechNet Guru Awards.


Thanks,

If my reply is helpful please mark as Answer or vote asHelpful.

My blog | Twitter | LinkedIn

This post is my own opinion and does not necessarily reflect the opinion or view of Microsoft, its employees, or other MVPs.

Creating multiple publish configurations

$
0
0

Hi,

I am looking at creating 2 different publish configurations for a WPF project. I am unable to do it from Project properties as the configurations seems to be grayed out. Is there a way to get around this? I tried to add the configuration to .csproj file, but in vain.

It would be great to have some help if someone has come across this issue.

Application hang ..

$
0
0

I got an application. it run fine...

If I let the app running and from another pc connect with rdp on the running pc. the app "can hang"

I Can't not click on any button... keyboard not working.. Other apps are ok

when I attach to the application with the debugger no thread is running

the only thing I can tell it seem to be waiting (see call stack OnThemeChanged, main thread)

  WindowsBase.dll!System.Windows.Threading.DispatcherSynchronizationContext.Wait(System.IntPtr[] waitHandles, bool waitAll, int millisecondsTimeout) Line 74 C#
  mscorlib.dll!System.Threading.SynchronizationContext.InvokeWaitMethodHelper(System.Threading.SynchronizationContext syncContext, System.IntPtr[] waitHandles, bool waitAll, int millisecondsTimeout) Unknown
  [Native to Managed Transition] 
  [Managed to Native Transition] 
  mscorlib.dll!System.Threading.WaitHandle.InternalWaitOne(System.Runtime.InteropServices.SafeHandle waitableSafeHandle, long millisecondsTimeout, bool hasThreadAffinity, bool exitContext) Unknown
  mscorlib.dll!System.Threading.WaitHandle.WaitOne(int millisecondsTimeout, bool exitContext) Unknown
  System.Windows.Forms.dll!System.Windows.Forms.Control.WaitForWaitHandle(System.Threading.WaitHandle waitHandle) Unknown
  System.Windows.Forms.dll!System.Windows.Forms.Control.MarshaledInvoke(System.Windows.Forms.Control caller, System.Delegate method, object[] args, bool synchronous) Unknown
  System.Windows.Forms.dll!System.Windows.Forms.Control.Invoke(System.Delegate method, object[] args) Unknown
  System.Windows.Forms.dll!System.Windows.Forms.WindowsFormsSynchronizationContext.Send(System.Threading.SendOrPostCallback d, object state) Unknown
  System.dll!Microsoft.Win32.SystemEvents.SystemEventInvokeInfo.Invoke(bool checkFinalization, object[] args) Line 1634 C#
  System.dll!Microsoft.Win32.SystemEvents.RaiseEvent(bool checkFinalization, object key, object[] args) Line 1314 C#
> System.dll!Microsoft.Win32.SystemEvents.OnThemeChanged() Line 992 C#
  System.dll!Microsoft.Win32.SystemEvents.WindowProc(System.IntPtr hWnd, int msg, System.IntPtr wParam, System.IntPtr lParam) Line 1495 C#
  [Native to Managed Transition] 
  [Managed to Native Transition] 
  WindowsBase.dll!System.Windows.Threading.Dispatcher.PushFrameImpl(System.Windows.Threading.DispatcherFrame frame) Line 1000 C#
  WindowsBase.dll!System.Windows.Threading.Dispatcher.PushFrame(System.Windows.Threading.DispatcherFrame frame) Line 978 C#
  PresentationFramework.dll!System.Windows.Application.RunDispatcher(object ignore) Unknown
  PresentationFramework.dll!System.Windows.Application.RunInternal(System.Windows.Window window) Unknown
  PresentationFramework.dll!System.Windows.Application.Run(System.Windows.Window window) Unknown
  PresentationFramework.dll!System.Windows.Application.Run() Unknown
  Maximum.Net.exe!Maximum.Presentation.App.Main() Line 51 C#


Data Binding to a data type that inherits from TreeViewItem

$
0
0

I have a TreeView that is binded to a data type called "File". Everything works fine until I make the "File" data type inherit from "TreeViewItem".

Working example:

Data Type:

public class File
    {
        public string FileName { get; set; }
        public string IconSource { get; set; }
        public ObservableCollection<File> Items { get; set; }
        public File()
        {
            Items = new ObservableCollection<File>();
        }

        public File(string name) : this()
        {
            FileName = name;
            this.IconSource = "/GameMaker;component/Resources/Icons/File.ico";
        }
    }

C# Code:

public MainWindow()
        {
            InitializeComponent();

            List<File> FileTree = new List<File>();
            Folder objFolder = new Folder("Objects"),
                            spriteFolder = new Folder("Sprites"),
                            scenesFolder = new Folder("Scenes");

            File object0 = new File("object0"),
                            object1 = new File("object1"),
                            object2 = new File("object2");

            objFolder.Items.Add(object0);
            objFolder.Items.Add(object1);
            objFolder.Items.Add(object2);

            FileTree.Add(objFolder);
            FileTree.Add(spriteFolder);
            FileTree.Add(scenesFolder);

            fileViewer.ItemsSource = FileTree;

        }

XAML:

<Window x:Class="GameMaker.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:GameMaker"
        mc:Ignorable="d"
        Title="LurkaEngine" Height="350" Width="525"><Window.Resources><ResourceDictionary><ResourceDictionary.MergedDictionaries><ResourceDictionary
                  Source="Resources/ResourceDictionary.xaml"></ResourceDictionary></ResourceDictionary.MergedDictionaries></ResourceDictionary></Window.Resources><Grid><TreeView x:Name="fileViewer" Height="281" VerticalAlignment="Top" Margin="0,18,0,0" ><TreeView.ItemTemplate><HierarchicalDataTemplate DataType="{x:Type local:File}" ItemsSource="{Binding Path=Items}"><StackPanel Orientation="Horizontal"><Image Source="{Binding Path=IconSource}" /><TextBlock Text="{Binding Path=FileName}" /></StackPanel></HierarchicalDataTemplate></TreeView.ItemTemplate></TreeView></Window>

This example works perfectly. The treeview displays like an explorer that shows folders and files with name and icons.

Changes made to the Data Type:

public class File : TreeViewItem
    {
        public string FileName { get; set; }
        public string IconSource { get; set; }
        //public ObservableCollection<File> Items { get; set; }
        public File()
        {
            //Items = new ObservableCollection<File>();
        }

        public File(string name) : this()
        {
            FileName = name;
            this.IconSource = "/GameMaker;component/Resources/Icons/File.ico";
        }
    }

Result: THe icons and header of the file disappear (actually I see nothing but the triangle that expends the "Objects" folder.)

I can't add images for some reason.

* NOTE: the "FOLDER" data type inherits from the "FILE" data type.

What should I do?

The reason I want the data type to inherit from "TreeViewItem" is so I can add some event handlers to the "File" objects.

Convert XAML to BAML- Need some efficient Tools

$
0
0

Hi,

I need to convert XAML to BAML. Please suggest me some efficient tools(Opensource).

Thank you,

Arun


Arun Aradhya

Datagrid with Entity data to drive lookup Comboboxes

$
0
0

My brain is still fighting all this binding stuff, it was never this hard on an IBM System/370 MVS in PL/1!

Any road up, I am trying to do something which I think is simple and obvious and can't untangle all the different bits. I might be tripping over the odd bug as well. Basically, I am trying to write a quick and dirty table maintenance system to set up a Sqlite database which will be used to drive a phone App. I have a number of tables of the form:

Table Characteristic(_id INT PRIMARY KEY,description CHAR);

These populate a number of other tables, e.g. 

Table Symptom (_id int PRIMARY KEY,
characteristic int,
another_code int,
more_codes int,
name char,
description char
);


So I want to maintain symptoms in a DataGrid. I populate the datagrid with a binding to the Symptoms DBSet via a Load(). I populate the lookup combobox columns from the lookup tables also from the DBSets I have loaded and bound.

So I get a Datagrid where the Symptom table has loaded and the lookup comboboxes have loaded too, but I can't figure out how to map the id's (which I have mapped to C# friendly names) to the row value ids and then get the row value ids updated when I select the description. In my mind, I am confident that the combobox is selecting a lookup row which just happens to display the description and the id will be lurking around, just finding the definition of this thing too baffling with the different syntaxes involved.

Here is the Entity definition

// The Table is there as Sqlite.EF6 seems to use the DBSet name if it is not there [Table("Symptom")] public class Symptom { [Key] [Column("_id")] // Mapping from Android convention public int id { get; set; } public int characteristic { get; set; } public string name { get; set; } public string description { get; set; } public int frequency { get; set; } public int location { get; set; } } [Table("Characteristic")] public class Characteristic_List { [Key] [Column("_id")] public int id { get; set; } public string description { get; set; } } [Table("Frequency")] public class Frequency_List { [Key] [Column("_id")] public int id { get; set; } public string description { get; set; } } public class DiagnosticContext : DbContext { public DiagnosticContext() { Database.SetInitializer<DiagnosticContext>(null); } public DbSet<Frequency_List> Frequencies { get; set; } public DbSet<Characteristic_List> Characteristics { get; set; } } public DbSet<Symptom> Symptoms { get; set; } }

Then for reasons too tedious to explain, I ended up with this approach in the Window code to get things up and running;

   public partial class MainWindow : Window
    {
        private DiagnosticContext context = new DiagnosticContext();


        public MainWindow()
        {
            InitializeComponent();
            Loaded += MainWindow_Loaded;
        }
        void MainWindow_Loaded(object sender, RoutedEventArgs e)
        {
// Load the ComboboxColumn entries

            context.Characteristics.Load();
            characteristics.ItemsSource = context.Characteristics.Local;
            characteristics.Items.SortDescriptions.Add(new SortDescription("description", ListSortDirection.Ascending));

            context.Frequencies.Load();
            frequencies.ItemsSource = context.Frequencies.Local;
            frequencies.Items.SortDescriptions.Add(new SortDescription("description", ListSortDirection.Ascending));



            characteristic_combo_col.ItemsSource = context.Characteristics.Local;
            frequency_combo_col.ItemsSource = context.Frequencies.Local;
            location_combo_col.ItemsSource = context.Locations.Local;

            context.Symptoms.Load();
            symptom_grid.ItemsSource = context.Symptoms.Local;


        }
        protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
        {
            base.OnClosing(e);
            this.context.Dispose();
        }

And here is the DataGrid set up:

<TabItem Header="Symptoms"><Grid Background="#FFE5E5E5"><DataGrid x:Name="symptom_grid" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" Height="508" Width="756" AutoGenerateColumns="False" ItemsSource="{Binding}"><DataGrid.Columns><DataGridComboBoxColumn x:Name ="characteristic_combo_col"  DisplayMemberPath="description" SelectedItemBinding="{Binding id, NotifyOnTargetUpdated=True, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" SelectedValueBinding="{Binding description, NotifyOnTargetUpdated=True, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Width="120" Header="Characteristic"/><DataGridComboBoxColumn x:Name="frequency_combo_col"  DisplayMemberPath="description" SelectedItemBinding="{Binding id, NotifyOnTargetUpdated=True, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"  SelectedValueBinding="{Binding description, NotifyOnTargetUpdated=True, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Width="120" Header="Frequency"/><DataGridComboBoxColumn x:Name="location_combo_col"  DisplayMemberPath="description" SelectedItemBinding="{Binding id, NotifyOnTargetUpdated=True, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" SelectedValueBinding="{Binding description, NotifyOnTargetUpdated=True, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Width="120" Header="Location"/><DataGridTextColumn Binding="{Binding name, NotifyOnTargetUpdated=True, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Width="190" Header="Name"/><DataGridTextColumn Binding="{Binding description, NotifyOnTargetUpdated=True, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Width="190" Header="Description"/></DataGrid.Columns></DataGrid></Grid></TabItem>

You may detect a hint of desperation and randomness in there! Before I added in 

NotifyOnTargetUpdated=True, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged

it at least dropped down lists, but with the above although it drops down lists it all gets a bit distressed (like me!) and red exclamation marks are the most it can produce!

So in plain English, I want a data grid with drop down selections to set codes in the target table based on the descriptions of those codes from lookup source tables, and to set the drop down selection based on the code in the first place - data entry 101 in my book! 

Making textboxes readonly using style

$
0
0
I've a C#/WPF application.On my Mainwindow.xaml,I'm programmatically loading other views.
There's a checbox on MainWindow.xaml.When its clicked, I need to make all textbox controls on the screen as readonly.
The code is working for controls on Mainwindow but not for textboxes on AView.xaml

What am I missing here please?Or is there any other way of achieving this functionality?

Thanks.

Here' my code:

MainWindow.xaml:

    <CheckBox IsChecked="{Binding IsCheckboxChecked, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
                 
    <ContentPresenter Content="{Binding CurrentViewModel}" >
                    <ContentPresenter.Resources>
                        <DataTemplate DataType="{x:Type ViewModel:VModelA}"  >
                            <Views:AView/>
                        </DataTemplate>                    
                </ContentPresenter>

MainWindowResources.xaml:

    <Style TargetType="TextBox" x:Key="ReadOnlyStyle">
            <Setter Property="IsReadOnly" Value="{Binding Path=IsCheckboxChecked}"/>        
        </Style>
    
    <Style TargetType="TextBox" x:Key="ReadOnlyStyleChild">
            <Setter Property="IsReadOnly" Value="{Binding Path=IsCheckboxCheckedChild}"/>
        </Style>

MainWindowViewModel.cs

    private static MainWindowViewModel _instance = new MainWindowViewModel();
    
    public static MainWindowViewModel Instance
            {
                get {
                    return _instance;
                }
            }
           
     public bool IsCheckboxChecked
            {
                get { 
                    
                    return m_isCheckboxChecked;
                }
                set
                {               
                    m_isCheckboxChecked = value;
                    OnPropertyChanged("IsCheckboxChecked");                
                }        
            }

VModelA.cs:

    public bool IsCheckboxCheckedChild
                {
                    get {
                        return MainWindowViewModel.Instance.IsCheckboxChecked;
                    }
                    
                }

AView.xaml

     <TextBox Style="{DynamicResource ReadOnlyStyleChild}">

C# 6.0 question

$
0
0

Hello folks!

What is the right way to realize the code below with async Task?

class A
{
    public virtual void Test()
    {

    }
}

\\\\\\\ should be\\\\\
public virtual async TaskTest()
    {

    }

\\\\\\\\\\\

class B : A
{
    public override void Test()
    {

    }
}


Suggestions and or advice would be very welcome!

How to move object in a list in wpf and c#

$
0
0

Hi

I am developing an application using c# and wpf. My requirement is to retrieve data from database and display it. User of this application can change the position of retrieved data in the list. Each data is a paragraph. How to achieve this requirement. The user can move a selected paragraph up or down in the list.

So far, I am able to retrieve the data from database. But could not able to find a way to display in a list so that those can be rearranged in the list. Hope you understand my requirement.

Please note, I want to do this in wpf.

As much detail, that will be great help.

cant detect enter key or space key in wpf, c# , visual studio?

$
0
0
private void textBox_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Enter)
            {
                MessageBox.Show("Enter key pressed");
            }
        }

The above key is detecting other keys but not enter and space key. I tried with key.Return but no result.

Need a digital signature?

$
0
0
I am developing a Unity Game using C#. It has been going great until I decided to write a custom launcher for the game to update it (just a simple WPF application). Whenever I try to have someone run the launcher, it gets blocked by their antivirus program. I did some research and supposedly I need a digital signature. I tried creating a test certificate in Visual Studio and added the long name key on the Signing tab, but to no avail. I am really stuck here and the $60-70 cost per year that I have seen is not going to work out. Do I have any other options?

How to align text individually in text box, c# wpf

$
0
0

Hi

I want to know how to set alignment property of text box in WPF. I used below code;

textBox.TextAlignment=TextAlignment.Center;

But it changes entire text alignment in the text box.  I dont want this.

Actually I am looking for

richTextBox1.SelectionAlignment = HorizontalAlignment.Center; (from winforms)

Similar code in wpf text box.

Exception Error in richtextbox.CaretPosition.GetCharacterRect when typing with non english language and Italic style

$
0
0

I am developing editor with RichTextBox under .Net 3.5 WPF environment VS2013 Ultimate Update 4 and VS2015 Community Update 3.

I need to check screen position of current caret position and scroll automatically scroller when I type any text.

code is here.

        private void Italicbtn_Click(object sender, RoutedEventArgs e)
        {
            editorctrl.SetFontProperties(richtextbox1, TextElement.FontStyleProperty, FontStyles.Italic);
            richtextbox1.Focus();
        }

        private void Richtextbox1_PreviewKeyDown(object sender, KeyEventArgs e)
        {
            Rect r = GetCurrentCaretPos();

            // scroller down
            //if (rect.Y > 400)
            //{
            //    scroller1.LineDown();
            //}
        }

        public Rect GetCurrentCaretPos()
        {
            Rect rect = richtextbox1.CaretPosition.GetCharacterRect(LogicalDirection.Backward);
            Debug.WriteLine(String.Format("CaretPos : {0} {1}", rect.X, rect.Y));

            return rect;
        }

typing language is non-english, Hangul korea.

If I type without Italic style, it's fine even if I type slow with Italic style.

But If I type a little fast with Italic style, Sample Application just shutdowns on VS2015.

My real Project with same Logic has System.ExecutionEngineException on VS2013.

Below is error stacks.

How can I fix it?

> WindowsBase.dll!MS.Internal.Invariant.FailFast(string message, string detailMessage) 알 수 없음
  WindowsBase.dll!MS.Internal.Invariant.Assert(bool condition, string invariantMessage) 알 수 없음
  PresentationFramework.dll!System.Windows.Documents.CaretElement.OnRenderCaretSubElement(System.Windows.Media.DrawingContext context) 알 수 없음
  PresentationFramework.dll!System.Windows.Documents.CaretElement.CaretSubElement.OnRender(System.Windows.Media.DrawingContext drawingContext) 알 수 없음
  PresentationCore.dll!System.Windows.UIElement.Arrange(System.Windows.Rect finalRect) 알 수 없음
  PresentationFramework.dll!System.Windows.Documents.CaretElement.ArrangeOverride(System.Windows.Size availableSize) 알 수 없음
  PresentationFramework.dll!System.Windows.FrameworkElement.ArrangeCore(System.Windows.Rect finalRect) 알 수 없음
  PresentationCore.dll!System.Windows.UIElement.Arrange(System.Windows.Rect finalRect) 알 수 없음
  PresentationFramework.dll!System.Windows.Documents.AdornerLayer.ArrangeOverride(System.Windows.Size finalSize) 알 수 없음
  PresentationFramework.dll!System.Windows.FrameworkElement.ArrangeCore(System.Windows.Rect finalRect) 알 수 없음
  PresentationCore.dll!System.Windows.UIElement.Arrange(System.Windows.Rect finalRect) 알 수 없음
  PresentationCore.dll!System.Windows.ContextLayoutManager.UpdateLayout() 알 수 없음
  PresentationCore.dll!System.Windows.ContextLayoutManager.UpdateLayoutCallback(object arg) 알 수 없음
  PresentationCore.dll!System.Windows.Media.MediaContext.InvokeOnRenderCallback.DoWork() 알 수 없음
  PresentationCore.dll!System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks() 알 수 없음
  PresentationCore.dll!System.Windows.Media.MediaContext.RenderMessageHandlerCore(object resizedCompositionTarget) 알 수 없음
  PresentationCore.dll!System.Windows.Media.MediaContext.RenderMessageHandler(object resizedCompositionTarget) 알 수 없음
  WindowsBase.dll!System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate callback, object args, bool isSingleParameter) 알 수 없음
  WindowsBase.dll!System.Windows.Threading.ExceptionWrapper.TryCatchWhen(object source, System.Delegate callback, object args, bool isSingleParameter, System.Delegate catchHandler) 알 수 없음
  WindowsBase.dll!System.Windows.Threading.Dispatcher.WrappedInvoke(System.Delegate callback, object args, bool isSingleParameter, System.Delegate catchHandler) 알 수 없음
  WindowsBase.dll!System.Windows.Threading.DispatcherOperation.InvokeImpl() 알 수 없음
  WindowsBase.dll!System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(object state) 알 수 없음
  mscorlib.dll!System.Threading.ExecutionContext.runTryCode(object userData) 알 수 없음
  [native에서 managed로 전환]
  mscorlib.dll!System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state) 알 수 없음
  mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state) 알 수 없음
  WindowsBase.dll!System.Windows.Threading.DispatcherOperation.Invoke() 알 수 없음
  WindowsBase.dll!System.Windows.Threading.Dispatcher.ProcessQueue() 알 수 없음
  WindowsBase.dll!System.Windows.Threading.Dispatcher.WndProcHook(System.IntPtr hwnd, int msg, System.IntPtr wParam, System.IntPtr lParam, ref bool handled) 알 수 없음
  WindowsBase.dll!MS.Win32.HwndWrapper.WndProc(System.IntPtr hwnd, int msg, System.IntPtr wParam, System.IntPtr lParam, ref bool handled) 알 수 없음
  WindowsBase.dll!MS.Win32.HwndSubclass.DispatcherCallbackOperation(object o) 알 수 없음
  WindowsBase.dll!System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate callback, object args, bool isSingleParameter) 알 수 없음
  WindowsBase.dll!System.Windows.Threading.ExceptionWrapper.TryCatchWhen(object source, System.Delegate callback, object args, bool isSingleParameter, System.Delegate catchHandler) 알 수 없음
  WindowsBase.dll!System.Windows.Threading.Dispatcher.WrappedInvoke(System.Delegate callback, object args, bool isSingleParameter, System.Delegate catchHandler) 알 수 없음
  WindowsBase.dll!System.Windows.Threading.Dispatcher.InvokeImpl(System.Windows.Threading.DispatcherPriority priority, System.TimeSpan timeout, System.Delegate method, object args, bool isSingleParameter) 알 수 없음
  WindowsBase.dll!System.Windows.Threading.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority priority, System.Delegate method, object arg) 알 수 없음
  WindowsBase.dll!MS.Win32.HwndSubclass.SubclassWndProc(System.IntPtr hwnd, int msg, System.IntPtr wParam, System.IntPtr lParam) 알 수 없음
  [native에서 managed로 전환]
  [managed에서 native로 전환]
  WindowsBase.dll!System.Windows.Threading.Dispatcher.PushFrameImpl(System.Windows.Threading.DispatcherFrame frame) 알 수 없음
  WindowsBase.dll!System.Windows.Threading.Dispatcher.PushFrame(System.Windows.Threading.DispatcherFrame frame) 알 수 없음
  WindowsBase.dll!System.Windows.Threading.Dispatcher.Run() 알 수 없음
  PresentationFramework.dll!System.Windows.Application.RunDispatcher(object ignore) 알 수 없음
  PresentationFramework.dll!System.Windows.Application.RunInternal(System.Windows.Window window) 알 수 없음
  PresentationFramework.dll!System.Windows.Application.Run(System.Windows.Window window) 알 수 없음
  PresentationFramework.dll!System.Windows.Application.Run() 알 수 없음

Assembly.Load executed in Thread, blocks ui

$
0
0

Executing the folowing code with "new Thread(new ThreadStart(tstest)).Start();" Freezes the UI while the Assemblys are Loading

How can I prevent the freezing of the UI?

void tstest()
{
foreach(var item in GetAsembys("folder with a lot *.exe files"))
{
}
}

    public class AssemblyHolder
    {

        #region Fields

        public Assembly originAssembly;

        public String originPath;

        private FileVersionInfo m_FileVersion;

        private Version m_AssemblyVersion;

        #endregion Fields

        #region Properties

        public FileVersionInfo FileVersion { get { return m_FileVersion = m_FileVersion ?? GetFileVersion(); } set { m_FileVersion = value; } }
        public Version AssemblyVersion { get { return m_AssemblyVersion = m_AssemblyVersion ?? GetAssemblyVersion(); } set { m_AssemblyVersion = value; } }

        #endregion Properties

        #region Constructors

        public AssemblyHolder(Assembly _asm, String _originPath)
        {
            originAssembly = _asm;
            originPath = _originPath;
        }

        #endregion Constructors

        #region Methods

        public static implicit operator Assembly(AssemblyHolder d)
        {
            return d.originAssembly;
        }

        public FileVersionInfo GetFileVersion()
        {
            return FileVersionInfo.GetVersionInfo(originPath);
        }

        private Version GetAssemblyVersion()
        {
            return originAssembly.GetName().Version;
        }

        #endregion Methods
    }

   public static List<AssemblyHolder> GetAsembys(String _rootfolder, SearchOption _option = SearchOption.AllDirectories)
        {
            try
            {
                List<AssemblyHolder> asm = new List<AssemblyHolder>();
                var executables = Directory.GetFiles(_rootfolder, "*.exe", _option);

                foreach (var item in executables)
                    try
                    {
                        using (Stream stream = File.OpenRead(item))
                        {
                            byte[] rawAssembly = new byte[stream.Length];
                            stream.Read(rawAssembly, 0, (int)stream.Length);
                            asm.Add(new AssemblyHolder(Assembly.Load(rawAssembly), item));
                        }
                    }
                    catch { }

                return asm;
            }
            catch { return default(List<AssemblyHolder>); }
        }

How to align text in rich text box individually in WPF application , c#?

$
0
0

Hi

Previously I was trying to achieve text alignment individually in text box but failed and even didnt get proper solution. So trying to achieve text alignment individually in rich text box.I searched a lot but no proper solution found.

My requirement is to allow user to align text as want. User can align first few line in center, then next few line in right alignment and next few lines with left alignment. But I wondered there is no such option called selectionalignment in textbox and richtextbox. 

Is there any way possible to set alignment of text individually in richtextbox? 

Please note I am developing this computer application using WPF and c#. 

Viewing all 18858 articles
Browse latest View live


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