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

Setting up a Datatrigger to set a listitem Background property when an ObservableCollection.Count property is zero.

$
0
0

I have a scenario where I have a Dictionary(Of TextObject, ObservableCollection(Of TextObject), a Parent / Children structure. TextObject is a simple class that exposes a Text property.I also have two Listboxes. One Listbox is bound to the Dictionary Keys and the other is bound to the ObservableCollection associated with the selected Key in the first Listbox. If a Parent has no children (the ObservableCollection.Count = 0) then I would like to change the background of the ListBoxItem to red. I cannot get the Datatrigger binding to work. I can certainly accomplish this with code but I would rather use the Datatrigger if I can. Any help would be appreciated.

Below is the code behind and XAML for a sample application.

XAML

<Window x:Class="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:WpfApplication1"
        mc:Ignorable="d"
        Title="MainWindow" Height="350" Width="525"><Window.Resources><DataTemplate x:Key="TextBlockTemplate"><TextBlock Text="{Binding Text}"
                       /></DataTemplate><Style x:Key="TestStyle"><Setter Property="Control.Background" Value="LightBlue"/><Style.Triggers><DataTrigger Binding="{Binding Acronyms.Item[DataContext].Count}"  Value="0"><Setter Property="Control.Background" Value="Red"/></DataTrigger></Style.Triggers></Style></Window.Resources><Grid><Grid.ColumnDefinitions><ColumnDefinition/><ColumnDefinition/></Grid.ColumnDefinitions><ListBox Name="lsbParents"
                     Height="200" Grid.Column="0"
                     ScrollViewer.VerticalScrollBarVisibility="Visible"
                     ItemTemplate="{StaticResource TextBlockTemplate}"
                     SelectionChanged="lsbParents_SelectionChanged"
                     ItemContainerStyle="{StaticResource TestStyle}"
                     ItemsSource="{Binding Path=Keys}"
                     /><ListBox Name="lsbChildren"
                     Height="200" Grid.Column="1"
                     ScrollViewer.VerticalScrollBarVisibility="Visible"
                     ItemTemplate="{StaticResource TextBlockTemplate}"
                     /></Grid></Window>

Visual Basic

Imports System.Collections.ObjectModel
Imports System.ComponentModel
Class MainWindow
    Dim _Dict1 As Dictionary(Of TextObject, ObservableCollection(Of TextObject)) _
        = New Dictionary(Of TextObject, ObservableCollection(Of TextObject))(New TextObject.EqualityCompare)

    Public Sub New()

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

        ' Add any initialization after the InitializeComponent() call.
        CreateData()
        Me.DataContext = Dict1
    End Sub

    Public ReadOnly Property Dict1() As Dictionary(Of TextObject, ObservableCollection(Of TextObject))
        Get
            Return _Dict1
        End Get
    End Property

    Private Sub CreateData()
        Dim Text1 As TextObject
        Dim TextCol As ObservableCollection(Of TextObject)
        For i As Integer = 1 To 5
            Text1 = New TextObject("Parent " + i.ToString)
            TextCol = New ObservableCollection(Of TextObject)
            For j As Integer = 1 To 5 - i
                TextCol.Add(New TextObject("Child " + j.ToString))
            Next
            _Dict1.Add(Text1, TextCol)
        Next

    End Sub

    Private Sub lsbParents_SelectionChanged(sender As Object, e As SelectionChangedEventArgs)
        lsbChildren.ItemsSource = _Dict1(CType(e.AddedItems(0), TextObject))
    End Sub
End Class

Public Class TextObject
    Implements INotifyPropertyChanged

    Public Sub New(value As String)
        _Text = value
    End Sub

    Public Event PropertyChanged As PropertyChangedEventHandler Implements INotifyPropertyChanged.PropertyChanged
    Protected Sub OnPropertyChanged(ByVal Value As String)
        RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(Value))
    End Sub

    Private _Text As String = ""
    Public Property Text() As String
        Get
            Return _Text
        End Get
        Set(ByVal value As String)
            _Text = value
            OnPropertyChanged("Text")
        End Set
    End Property

    Public Class EqualityCompare
        Implements IEqualityComparer(Of TextObject)

        Public Shadows Function Equals(x As TextObject, y As TextObject) As Boolean Implements IEqualityComparer(Of TextObject).Equals
            Return x.Text = y.Text
        End Function

        Public Shadows Function GetHashCode(obj As TextObject) As Integer Implements IEqualityComparer(Of TextObject).GetHashCode
            Return obj.Text.GetHashCode
        End Function
    End Class
End Class


I want to property grid open on Treeview item selection using MVVM

$
0
0

Hi all,

Please find bellow attached image.

I want to property grid open on treeView  item selection in WPF/MVVM 

how its possible.

Thanks


A.Acharya Feedback to us Develop and promote your apps in Windows Store Please remember to mark the replies as answers if they help and unmark them if they provide no help.

How to catagerize/Grouping list view according to column

$
0
0

We have list view with Nth column, e.g. stop 1,2,3,4,5...Nth. We will need to show data in each stop and if we have no data for any stop then we will show empty image. Default row will be 10 and Nth column. Nth column means user will be enter the column number and we will display data from the data base for the each stop . You can see the List example image

How to design in the wpf. Please help  me.

Who will be crowned the last WPF Guru of 2016!!

$
0
0

Calling all wise men! And all the Wise Ladies!

Join us and rejoice!

THE FINAL CHALLENGE OF 2016!!

December 2016 Guru, it’s time to share great skills as a TechNet Wiki article and WIN medal(s). Medals? Yes, you can share multiple articles in the same or different categories! Now, navigate to TechNet Guru Competition December 2016  to choose your categories and if it’s not listed add your content in Miscellaneous Category!

New and last month of the year 2016. It’s time for us to wave hands to say "bye bye 2016" by winning TechNet Wiki Guru medals. Let’s make this December to Remember! 

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

A snippet you share can make you a December 2016 TechNet Wiki Guru in your favorite category and this is official Microsoft TechNet recognition!

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 favorite technology will help us learn the active members in each community. 

Feel free to ask any questions below.

More about TechNet Guru Awards.

You Share We Care!

TechNet Wiki Addict Chen V and ...


Thanks,


Ed Price, Azure Development Customer Program Manager (Blog,Small Basic, Wiki Ninjas, Wiki)

Answer an interesting question? Create a wiki article about it!

Isolated Shell Properties Window

$
0
0
I have a wpf window that I drag and drop user controls to the window. Once the object is on the window I would like the ability for the user to click on objects and have the Properties Window display data about that User Control.   I know how to setup the User Control my question is how do I tell the Isolated Shell Properties Window that an object is selected and how do I pass that object to the Properties window so it can display the data.

Trouble with a property with the Size3D type

$
0
0

Hi,
I have the following problem with a custom control for WPF.
If a property of the custom control has the Size3D type (or any type from the System.Windows.Media.Media3D namespace), this property is hidden in the Property Grid of the Visual Studio,
In the same time, the property with the Size type is visible.
What am I doing wrong?

The custom control code:

    public class CustomControl : Control {
        public static readonly DependencyProperty SizeProperty = DependencyProperty.Register("Size",
            typeof(Size), typeof(CustomControl));
        public static readonly DependencyProperty Size3DProperty = DependencyProperty.Register("Size3D",
            typeof(Size3D), typeof(CustomControl));

        public Size Size {
            get { return (Size)GetValue(SizeProperty); }
            set { SetValue(SizeProperty, value); }
        }
        public Size3D Size3D {
            get { return (Size3D)GetValue(Size3DProperty); }
            set { SetValue(Size3DProperty, value); }
        }
    }


Display message on selecting DVD drive from Folder Tree

$
0
0

Hi,

I have a WPF application, which includes Folder Tree displaying logical drives.

I need to display a message "Please insert disk into DVD Drive" when user selects DVD drive from Folder Tree.

Refer the attached screenshot for reference.

InsertDisk

Thanks

Vijay Zalaki

using UIElements on DataTemplate

$
0
0

I have the following code:

<TabControl ItemsSource="{Binding Tabs"}>
...<TabControl.ContentTemplate><DataTemplate DataType="{x:Type vm:TabVM}"><TextBox></TextBox><TextBox Text="{Binding SomeProperty}"></TextBox></DataTemplate></TabControl.ContentTemplate></TabControl>

Now, what happens in the first TextBox is that Text is shared throught all tabItems. (unwanted)

The second instead works as expected (with Text relative to VM binded property).

Hovever I want the first to be independent for each tabItem.

What's wrong with that?



Rotating World Map

$
0
0

Hello All,

I have created a map using c# & lat long information, but the problem is how do I make it rotating map with repeating x-axis and y-axis. For example consider the flights flying over pacific ocean from North America to Asia in this case I need to have two maps side by side (which is not an optimal solution.) or find a way to horizontally repeat map, even x-axis and y-axis needs to be repeating.

If you guys are still confused then please check the flight path on maps from Seattle(SEA) to Beijing(PEK).

Any optimal solution for implementing this functionality would be very much appreciated.

Thanks in Advance.

Issue with collection editor's property grid categories

$
0
0

Hi,

Several properties are added to incorrect categories in a Collection Editor.  In the same time this properties in the Property Grid in the Visual Studio have correct categories.

My custom control code:

public class ChildrenPanel : Panel {
        public static readonly DependencyProperty Value1PropertyProperty =
          DependencyProperty.Register("Value1Property", typeof(double), typeof(ChildrenPanel), new FrameworkPropertyMetadata());
        public static readonly DependencyProperty Value2PropertyProperty =
          DependencyProperty.Register("Value2Property", typeof(double), typeof(ChildrenPanel), new FrameworkPropertyMetadata());
        public static readonly DependencyProperty Value3PropertyProperty =
          DependencyProperty.Register("Value3Property", typeof(double), typeof(ChildrenPanel), new FrameworkPropertyMetadata());

        [Category("Category1")]
        public double Value1Property {
            get { return (double)GetValue(Value1PropertyProperty); }
            set { SetValue(Value1PropertyProperty, value); }
        }
        [Category("Category1")]
        public double Value2Property {
            get { return (double)GetValue(Value2PropertyProperty); }
            set { SetValue(Value2PropertyProperty, value); }
        }
        [Category("Category2")]
        public double Value3Property {
            get { return (double)GetValue(Value3PropertyProperty); }
            set { SetValue(Value3PropertyProperty, value); }
        }
    }

Result in a collection editor:

Result in the property grid:

Please help to find some solution! Thanks, Antony.


Text search and extraction in pdf file

$
0
0

I am working for text search and extraction from pdf using third party dll itextsharp.

I am getting the text on searching but not only that text, the whole text of that page.

I thought to use phrases or chunks so that I can get pre-and post of that text only along with it instead of whole page text. Can anyone suggest me code for phrases or anything else which I can use for it. Thanks!

My code is:

string searchText =null;

           string filename = System.AppDomain.CurrentDomain.BaseDirectory;

            filename =@"C:\test.pdf";

            searchText = textBox.Text.ToString();

           

           List<int> pages = newList<int>();

           if (File.Exists(filename))

            {

               PdfReader pdfReader =newPdfReader(filename);

               List<Phrase> PhraseList = newList<Phrase>();

               for (int page = 1; page <= pdfReader.NumberOfPages; page++)

                {

  ITextExtractionStrategy strategy =SimpleTextExtractionStrategy();

  string currentPageText =PdfTextExtractor.GetTextFromPage(pdfReader, page, strategy)

                   if (currentPageText.Contains(searchText))

                    {

                        pages.Add(page);

                        textBox1.AppendText(PdfTextExtractor.GetTextFromPage(pdfReader, page));

                        textBox1.Text += pages.ToString();

                    }

                }

                pdfReader.Close();

            }

How to build a big Canvas

$
0
0

Dear all,

I am buidling for a customer a specific collaborative application quite similar what digital board are showing those past year but much simpler.

In fact what I need to do is the following :

I need to build a kind of big canvas at least 3 time the size of the screen in order that people can start to write notes in screen and if there is no more room they can slide the screen to right, up or down.

But with that I need to add a can of Picture in picture to show the full canvas area and the used area as shown below :

As you can see from picture above the canvas is bigger that the visible screen area. The small window on bottom letft is showing the full canvas with object position to informed user where conatent are located. Then user knows that if he scrool the main screen area to right he will be able to see the other content type.

If an object is moved from the main screen it is also reflected in the small window.

Any idea how to build such interaction where small windows represent the whole canvas area ?

Thanks for help

Override a resource

$
0
0

I have a pair of resources in a resource dictionary like this:

<SolidColorBrush x:Key="CLOSE-ICON-01_cls-1_fill" Color="#FF373D41"/><DrawingImage x:Key="CLOSE-ICON-01"><DrawingImage.Drawing><DrawingGroup Opacity="1"><DrawingGroup.Children><GeometryDrawing Brush="{DynamicResource CLOSE-ICON-01_cls-1_fill}" Pen="{x:Null}"><GeometryDrawing.Geometry><PathGeometry FillRule="Nonzero" Figures="M8.48999977111816,1.1675656423904E-06L9.34000015258789,1.1675656423904E-06C9.40999984741211,0.810000002384186 10.1300001144409,1.12999999523163 10.5999994277954,1.60000050067902 35.1333351135254,26.1533336639404 59.6666679382324,50.7066650390625 84.1999969482422,75.2600021362305 85.1999969482422,76.2600021362305 85.7600021362305,76.5999984741211 86.9800033569336,75.379997253418 111.779998779297,50.4599990844727 136.613327026367,25.6033325195313 161.479995727539,0.810000360012054 161.71435546875,0.552015364170074 161.934661865234,0.281626671552658 162.139999389648,1.1675656423904E-06L162.559997558594,1.1675656423904E-06C164.949996948242,2.41000008583069 167.259994506836,4.90000009536743 169.75,7.20000076293945 171.100006103516,8.44999980926514 171.149993896484,9.19999980926514 169.75,10.5099992752075 154.123336791992,26.0499992370605 138.539993286133,41.6366653442383 123,57.2700004577637 114.050003051758,66.2699966430664 105.129997253418,75.1999969482422 96.120002746582,84.0899963378906 94.879997253418,85.3099975585938 94.8399963378906,85.879997253418 96.120002746582,87.0899963378906 120.660003662109,111.550003051758 145.183334350586,136.026672363281 169.690002441406,160.520004272461 171.160003662109,161.990005493164 171.169998168945,162.789993286133 169.690002441406,164.119995117188 167.719680786133,165.842025756836 165.865600585938,167.692779541016 164.139999389648,169.660003662109 162.929992675781,171.029998779297 162.210006713867,171.089996337891 160.839996337891,169.720001220703 145.66667175293,154.573333740234 130.486663818359,139.429992675781 115.300003051758,124.290000915527 105.849998474121,114.839996337891 96.379997253418,105.410003662109 87,95.9000015258789 85.870002746582,94.7600021362305 85.3600006103516,94.8199996948242 84.2600021362305,95.9000015258789 59.7333335876465,120.5 35.2000007629395,145.080001831055 10.6599988937378,169.639999389648 9.1899995803833,171.110000610352 8.40999984741211,171.119995117188 7.03999900817871,169.639999389648 4.82000017166138,167.179992675781 2.35999989509583,164.929992675781 0.0400007478892803,162.639999389648 0.0133333336561918,162.446670532227 0,162.276672363281 0,162.130004882813 0.469999998807907,161.710006713867 1,161.320007324219 1.41000020503998,160.880004882813 25.9566669464111,136.339996337891 50.5099983215332,111.806663513184 75.0699996948242,87.2799987792969 76.3399963378906,86 76.5,85.4000015258789 75.129997253418,84 50.5833320617676,59.5800018310547 26.0733337402344,35.1133346557617 1.59999930858612,10.6000003814697 1.12999999523163,10.1300001144409 0.810000002384186,9.40999984741211 0,9.34000110626221L0,8.48999881744385C2.42876482009888,5.28536033630371,5.28536033630371,2.42876482009888,8.48999977111816,1.1675656423904E-06z" /></GeometryDrawing.Geometry></GeometryDrawing></DrawingGroup.Children></DrawingGroup></DrawingImage.Drawing></DrawingImage>

This resource dictionary is generated by an external tool that is converting a .svg file to the XAML resource dictionary.  For that reason I prefer not to modify the resource dictionary since future updates will overwrite any changes that I make.

I am consuming the resource like this.

<Image Grid.Column="2" Source="{DynamicResource CLOSE-ICON-01}" Margin="15" Height="25" ><Image.Resources><SolidColorBrush x:Key="CLOSE-ICON-01_cls-1_fill" Color="Blue"/></Image.Resources></Image>

I was hoping to be able to override the color of the drawing by establishing a new resource with the same key as the brush, but at a nearer scope.  Resharper certainly seems to think that this will override the resource.

Unfortunately, the original color for the drawing is displayed.

Does anyone have any suggestions on how I can change the color used in my drawing outside of the automatically generated resource dictionary?

WPF Double

$
0
0

Please help me understand what happen why 

startpoint.X + 62.7852 =837.952000000008 

where startpoint.X=775,2



Canvas Control which Rotates.

$
0
0

Hi All

I am trying to make a custom canvas control that allows me to rotate it (or its children) at runtime by dragging with the mouse. I have an example of something that works nicely but is not in a control.

I would like the control to look like a canvas, behave like a canvas and effectively be just like a canvas. Which means that it can have lots of children, some of which maybe other custom canvas controls.

<Window
        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:Puppet"
        xmlns:Views="clr-namespace:Puppet.Views" x:Name="window" x:Class="Puppet.MouseWindow"
        mc:Ignorable="d"
        DataContext="{Binding RelativeSource={RelativeSource Self}}"
        Title="Mouse"
        Height="517" Width="339"><Canvas x:Name="Layout" RenderTransformOrigin="0.483,0.37"><Canvas x:Name="Person" Width="320" Height="480" RenderTransformOrigin="0.5,0.375"><Canvas.RenderTransform><TransformGroup><ScaleTransform/><SkewTransform/><RotateTransform Angle="{Binding Angle, ElementName=window}"  /><TranslateTransform/></TransformGroup></Canvas.RenderTransform><Ellipse x:Name="Leg" Fill="#FFDCD8BC" Height="190" Canvas.Left="145" Stroke="Black" Canvas.Top="170" Width="30" MouseLeftButtonDown="Leg_PreviewMouseLeftButtonDown" MouseUp="Leg_PreviewMouseLeftButtonUp" MouseMove="Leg_PreviewMouseMove"/><Ellipse Fill="#FFDCD8BC" Height="10" Canvas.Left="155" Stroke="Black" Canvas.Top="175" Width="10"/></Canvas></Canvas></Window>

and the code behind

using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;

namespace Puppet
{
    public partial class MouseWindow : Window
    {
        public MouseWindow()
        {
            InitializeComponent();
        }
        public static readonly DependencyProperty AngleProperty =
            DependencyProperty.Register("Angle", typeof(double), typeof(MouseWindow), new UIPropertyMetadata(0.0));

        public double Angle
        {
            get { return (double)GetValue(AngleProperty); }
            set { SetValue(AngleProperty, value); }
        }


        private void Leg_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            UIElement el = (UIElement)sender;
            if (el != null)
            {
                el.CaptureMouse();
            }
        }

        private void Leg_PreviewMouseMove(object sender, MouseEventArgs e)
        {
            if (e.LeftButton == MouseButtonState.Pressed)
            {
                UIElement el = (UIElement)sender;
                if (el != null && el.IsMouseCaptured)
                {
                    Point origin = GetOrigin(Person);
                    Point currentLocation = e.GetPosition(this);

                    this.Angle = GetAngleDegree(origin, currentLocation);
                }
            }
        }

        private void Leg_PreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            UIElement el = (UIElement)sender;
            if (el != null)
            {
                el.ReleaseMouseCapture();
            }
        }

        private static double GetAngleDegree(Point origin, Point target)
        {
            double degrees = 270 - (Math.Atan2(origin.Y - target.Y, origin.X - target.X)) * (180 / Math.PI);
            return -(degrees % 360);
        }

        private Point GetOrigin(Canvas uc)
        {
            double width = uc.Width;
            double height = uc.Height;

            Point origin = uc.RenderTransformOrigin;

            return new Point(width * origin.X, height * origin.Y);
        }
    }
}

Now this works nicely. It has smooth drag operation. The problem is that I am going to have a lot of these items on a window so I want to make a control that has the same functionality.

What have I tried

Attempt 1

I tried to make a custom canvas but it gets a jerky animation. I figure this is because once I start rotating the canvas it changes the relative position of the mouse or the origin.

<Canvas
    x:Name="MyRotateCanvas"
    x:Class="Puppet.Views.RotateCanvas"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:local="clr-namespace:Puppet.Views"
    DataContext="{Binding RelativeSource={RelativeSource Self}}"
    mc:Ignorable="d"
    PreviewMouseLeftButtonDown="UserControl_PreviewMouseLeftButtonDown"
    PreviewMouseMove="UserControl_PreviewMouseMove"
    PreviewMouseLeftButtonUp="UserControl_PreviewMouseLeftButtonUp"
    d:DesignHeight="320" d:DesignWidth="480"><Canvas.RenderTransform><TransformGroup><ScaleTransform/><SkewTransform/><RotateTransform Angle="{Binding Angle, ElementName=MyRotateCanvas}"  /><TranslateTransform/></TransformGroup></Canvas.RenderTransform></Canvas>

The code behind is similar to the code behind posted above.

Attempt 2

Create a user control which contains a canvas. Then I could just spin the canvas.

<UserControl
    x:Class="Puppet.Views.RotateControl"
    x:Name="Rotator"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:local="clr-namespace:Puppet.Views"
    mc:Ignorable="d" d:DesignHeight="300" d:DesignWidth="300"><UserControl.Template><ControlTemplate><Canvas><ItemsControl Name="_itemsControl" ItemsSource="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}, Path=ItemsSource}"/></Canvas></ControlTemplate></UserControl.Template></UserControl>

The problem with this is the usercontrol is not really a layout control. So I add a control template, but the items control cannot find the items in the code behind.

using System.Windows.Markup;

namespace Puppet.Views
{
    [ContentProperty("Items")]
    public partial class RotateControl : UserControl
    {
        public static readonly DependencyProperty ItemsSourceProperty = ItemsControl.ItemsSourceProperty.AddOwner(typeof(RotateControl));

        public IEnumerable ItemsSource
        {
            get { return (IEnumerable)GetValue(ItemsSourceProperty); }
            set { SetValue(ItemsSourceProperty, value); }
        }

        public ItemCollection Items
        {
            get { return _itemsControl.Items; }
        }

        public RotateControl()
        {
            InitializeComponent();
        }
    }
}

The question is "How do I get a canvas control that will rotate (its children) around the origin like in the first example."




How I can write this in code

$
0
0

How I can write this in code

<Path Data="M21.9,26.4 C21.9,40.704175 17.109447,52.3 11.2,52.3 C5.2905532,52.3 0.5,40.704175 0.5,26.4 C0.5,12.095825 5.2905532,0.5 11.2,0.5 C17.109447,0.5 21.9,12.095825 21.9,26.4 z" Fill="#FFF4F4F5" HorizontalAlignment="Left" Height="52.8" Margin="136.2,55.2,0,0" Stretch="Fill" Stroke="Black" VerticalAlignment="Top" Width="22.4"/>

  

Printing Issues in Windows 10

$
0
0

At my company we use Document Viewers containing FixedDocuments wrapping UserControls to display forms to our users.  It works great, but on Windows 10 we have noticed a couple of printing related issues that we just can't figure out:

  1. One of the forms will simply not print from Windows 10.  We have tried it on two different computers with two different printers (one printer shared by both machines on a network and both of different manufacturer).
  2. The lines of some simple path geometry objects are not printing.

I have confirmed that these issues occur in both our application and when the xaml is simplified enough to be loaded into and printed from Internet Explorer.

For the first issue the form prints fine on the shared printer from windows 7.  The only clue I have been able to find as a possible cause is that the form's background (rendered as a DrawingBrush on a canvas' background) has a umber of very deeply nested Drawing groups (at least 20 deep); each of which draw a single line.  The xaml was created by a utility of ours and not by hand.

The only other clue I have been able to gather is that when printing the form on one of the printers from Internet Explorer we actually got a print error in the Windows event viewer operational print logs.  While it didn't say much; the driver isolation event did return an error code 0x103 (on a local Brother USB connected printer).

The path geometry for the second issue is as follows:

<GeometryDrawing x:Name="path26" ><GeometryDrawing.Pen><Pen Brush="#FF231F20" Thickness="0.1" StartLineCap="Flat" EndLineCap="Flat" LineJoin="Miter" /></GeometryDrawing.Pen><GeometryDrawing.Geometry><PathGeometry FillRule="Nonzero" Figures="M351.001,579L361.001,579 361.001,567 351.001,567 351.001,579z" /></GeometryDrawing.Geometry></GeometryDrawing>

This same shape is repeated in several places, and one or more of the sides of the box (which is what the PathGeometry described above is) are missing when printing.  The same line segments are missing when printed from both of our printers.  I've tried making the lines thicker, and while that does make the missing sides appear, the sides that were always printed don't change and look strange.

Neither of these issues occur when printing to a virtual printer like the Adobe PDF Printer.  When printing to the Adobe PDF printer the form that doesn't normally print will and all box sides will be present in the resulting PDF file.

I can work around both of these issues, but that would mean touching a whole lot of code (we have a lot of forms) and we would really like to understand what is going on and not just stick a band aid on it.  

If someone else has encountered these issue or has any idea as to what is going on and can shed some light on these issues that would be very helpful.


Inkcanvas strokes Undo & Redo?

$
0
0

Hi,all

A inkcanvs, If I draw some strokes with Pen, and Erase some strokes with EraseBypoint and ErasebyStroke,

and also selection, Delete ,Move ,Scale strokes ,

Can I implement those operate Undo and redo ?

Thanks

How to select part of 3d object?

$
0
0
Hi, I'm using helix 3d toolkit. I've successfully loaded 3d model in wpf application and i'm able to move,rotate,scale,zoom the 3d model. The 3d model i have is a stl file. I have searched alot but haven't found any proper source from where i can learn. What  i want is i want to select a particular part of 3d model using mouse click, and then move it where i want. Make animation of this movement. For example if i move a part from x position to y position so i want to create its animation. Please help me out and provide me good sources where i can learn to do these things. Thanks :)

best book for WPF

$
0
0

hi there
which is the best book to learn WPF

Viewing all 18858 articles
Browse latest View live


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