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

XAML Parser?

$
0
0

Are they any XAML parsers available? We have a requirement to parse the XAML files and extract the required information. Microsoft provides XAML Toolkit(http://archive.msdn.microsoft.com/XAML/), but it's in CTP and for som reason archived. Not sure what the roadmap is. Any inputs in this regard will be very helpful


WPF: How to begin a specific child animation of the Storyboard class?

$
0
0

Situation: The Storyboard class instance has many children.

Question: How to Begin/Pause only one of them.

Code:

    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();

            this.Loaded += MainWindow_Loaded;
        }

        Line line;

        void MainWindow_Loaded(object sender, RoutedEventArgs e)
        {
            Canvas canvas = new Canvas();
            canvas.Background = Brushes.Black;
            this.Content = canvas;

            line = new Line();
            line.Stroke = Brushes.White;
            line.X1 = 0;
            line.Y1 = 0;
            line.X2 = 100;
            line.Y2 = 100;

            canvas.Children.Add(line);

            Animation();
        }

        private void Animation()
        {
            ThicknessAnimation ta = new ThicknessAnimation();
            ta.Duration = TimeSpan.FromSeconds(1);
            ta.From = new Thickness(0, 0, 0, 0);
            ta.To = new Thickness(300, 300, 0, 0);
            ta.RepeatBehavior = RepeatBehavior.Forever;

            Storyboard sb = new Storyboard();
            Storyboard.SetTarget(ta, line);
            Storyboard.SetTargetProperty(ta, new PropertyPath(Line.MarginProperty));
            sb.Children.Add(ta);
            //sb.Children[0].Begin();
        }
    }

How to make a line chart in wpf

$
0
0

Hi All,

I am working on a WPF project based on .Net 3.5, there is a line chart in this project as the follow:

I find WPF Toolkit is a free control for chart in wpf, so I write code as the follow:

xmlns:datavis="clr-namespace:System.Windows.Controls.DataVisualization;assembly=System.Windows.Controls.DataVisualization.Toolkit"
             xmlns:charting="clr-namespace:System.Windows.Controls.DataVisualization.Charting;assembly=System.Windows.Controls.DataVisualization.Toolkit"<Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="10" Grid.Column="1" Grid.Row="0"><charting:Chart x:Name="waitingtasks" BorderBrush="Transparent" BorderThickness="0" VerticalAlignment="Stretch" Title="Waiting Tasks"><charting:Chart.TitleStyle><Style TargetType="datavis:Title"><Setter Property="HorizontalAlignment" Value="Left"/><Setter Property="Foreground" Value="White"/></Style></charting:Chart.TitleStyle><charting:Chart.LegendStyle><Style TargetType="datavis:Legend"><Setter Property="Width" Value="0" /></Style></charting:Chart.LegendStyle><charting:Chart.Axes><charting:LinearAxis Orientation="X" Title="Time" Interval="20" ShowGridLines="False"/><charting:LinearAxis Title="Number of Waiting Tasks" Orientation="Y" Interval="5" ShowGridLines="False"/></charting:Chart.Axes><charting:LineSeries DependentValuePath="Value" IndependentValuePath="Key" ItemsSource="{Binding}" IsSelectionEnabled="True"
                                    AnimationSequence="FirstToLast"/></charting:Chart>

But I get an error:

Could not load file or assembly 'WPFToolkit, Version=3.5.40128.1, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.

It's very wired. Nothing to do with WPFToolkit assembly. 

Any idea? or Is there other free controls for chart in wpf?

Thanks.

how to draw an ellipse in inkcanvas of wpf?

$
0
0

现在要用inkcanvas画图,想画一个可以用inkcanvas自带的橡皮能够擦出的圆,应该怎么画?用ellipsegeometry和ellipse都试了,能画出来,但是不能用橡皮擦擦掉,求解

recently i want to draw a ellipse in wpf using inkcanvas,i used ellipse and ellipsegeometry to draw a ellipse, but it can not be removed by eraser of inkcanvas, so how can i draw an ellipse which can be remove by eraser in inkcanvas

Drag and Drop does not work starting windows 8.1

$
0
0

Hi, 

we have a WPF application that runs in a different thread from an activex

                    var t = new Thread(() =>
                    {
                        m_CustomizerApplication = new App();
                        m_CustomizerApplication.ApplicationArguments = args;
                        m_CustomizerApplication.DispatcherUnhandledException += new System.Windows.Threading.DispatcherUnhandledExceptionEventHandler(m_CustomizerApplication_DispatcherUnhandledException);
                        m_CustomizerApplication.InitializeComponent();

                        m_CustomizerApplication.Run();

                    });

                    t.SetApartmentState(ApartmentState.STA);
                    t.Start();

when running as a standalone drag and drop function just perfect, however starting windows 8.1, we can "catch" the object to drag but starting there all other operations fail (cursor displaying where we drag to, drop action is not being applied, etc.)

we experience it in 2 different WPF application which when in standalone works just perfect and when being raised from an activeX the drag and drop just does not work. any suggestions? 

Programatically set focus on the next control

$
0
0
Hi all. I have a WPF Window, and I'd like the user to be able to focus on the next element with just pressing Enter, instead of Tab, but I don't want to write event handlers for every element in the form? Is there a way to programatically tell the window to move the focus to the next element?

Thanks.
:. HUGONNE .: Please mark as answer if the post helps. Coding thougts - http://hugonne.blogspot.com/

MVVM Architecture

$
0
0
I am looking for a sample app that implements EF6 (POCO) with the UOW pattern and does not use WCF but a direct database connection. The app is WPF MVVM (the use of IOC would be a bonus). 

suggested architectures for wpf

$
0
0

what are the suggested types of architectures for developing robust wpf application.

which would make use of observable collections and other binding features of wpf.


DataGrid

$
0
0
DataGrid How do I read until data.
I've written record comes only codes

public static List<GenelOdeme> KasaRaporuGoster(System.Windows.Controls.DataGrid grid)
        {
            List<GenelOdeme> list = new List<GenelOdeme>();
            {
                GenelOdeme insert = new GenelOdeme();
                foreach(DataRowView row in grid.Items)
                {
                    insert.number = Convert.ToInt32(row.Row.ItemArray[0]);
                    insert.adisoyadi = row.Row.ItemArray[1].ToString();
                }
                list.Add(insert);
                return list;
            }
        }
Thanks;

WPF Menu Binding Issues.

$
0
0

Hi All,

I want to create a Custom Menu like the screenshot below,

When click the arrow button, it will display the Types. When Click the item, such asEasy, it will display in the TextBox. 

What I have done now, I have create the basic style for this menu. But have some issue in Binding,

My source class and ViewModel like this,

    public partial class CustomMenu : UserControl
    {
        public CustomMenu()
        {
            InitializeComponent();

            this.DataContext = new ViewModel();
        }
    }

    public class QuestionType
    {
        public string Name { get; set; }

        public ICollection<QuestionType> Types { get; set; }
    }

    public class ViewModel
    {
        public ICollection<QuestionType> QuestionTypes { get; set; }

        public ViewModel()
        {
            QuestionTypes = new List<QuestionType>()
            {
                new QuestionType() { Name="Completion"},
                new QuestionType() { Name="Easy"},
                new QuestionType() { Name="MoreType", Types = new List<QuestionType>()
                {
                    new QuestionType() { Name="SingleChoice"},
                    new QuestionType() { Name="MultiChoice"},
                    new QuestionType() { Name="Blend"},
                } },
            };
        }
    }

And I bound to MenuItem, 

<MenuItem ItemsSource="{Binding QuestionTypes}"><MenuItem.Resources><HierarchicalDataTemplate DataType="{x:Type local:QuestionType}"
                                                  ItemsSource="{Binding Types}"><TextBlock Text="{Binding Name}"/></HierarchicalDataTemplate><DataTemplate DataType="{x:Type local:QuestionType}"><TextBlock Text="{Binding Name}"/></DataTemplate></MenuItem.Resources><MenuItem.ItemContainerStyle><Style TargetType="{x:Type MenuItem}"><Setter Property="Command" Value="{Binding XXXX}"/></Style></MenuItem.ItemContainerStyle></MenuItem>

When I run the application, It occurred an exception:

Exception thrown: 'System.Windows.Markup.XamlParseException' in PresentationFramework.dll

Additional information: 'Set property 'System.Windows.ResourceDictionary.DeferrableContent' threw an exception.' Line number '187' and line position '22'.

Another question, When I click the MenuItem, I need to display the Menu Header text in the EditTextBox.

I have uploaded my project on OneDrive. You can download and reproduce this issue.

Download link: http://1drv.ms/1JWa0h8.

Thanks a lot.

Working with caret in Text Formatter API

$
0
0

Hello!

I'm creating simple WPF text editor via Text Formatter API. I've already done some of the basic functionality and now I need to add a caret support. I also have a visual caret (just a line with blinking animation) that should be synchronized with rendered text. I found a bunch of methods in TextLine class, such as GetNextCaretCharacterHit , GetPreviousCaretCharacterHit , GetBackspaceCaretCharacterHit . But the documentation information about them is ...quite scarce.Could somebody who has some experience in that field explain how to deal with these methods, because I have almost no idea about that?

I tried to search the information in the internet, but as a result I found nothing.

I would be grateful for any help!

how to change the backround of the binded tab item

$
0
0

       <TabControl TabStripPlacement="Top"  ItemsSource="{Binding Settings}" Background="#FF2D2D30" SelectedIndex="{Binding SelectedTab}">            
            <TabControl.ItemTemplate>
                <DataTemplate>                    
                    <TextBlock Text="{Binding Header}" Margin="20" Foreground="Gray"/>                   
                </DataTemplate>
            </TabControl.ItemTemplate>

how to set the background of the tab item. my current knowledge doesn't permit me because of known limitations.

Localize source code comments

$
0
0

Hi to all the ML.

In a WPF UserControl I'd like to localize the "PropertyTabName" and the "DescriptionToolTip"of a DependencyPropertywhendisplayed in the property grid.

 ''' <summary>
        ''' Identifies the char size Dependency Property
        ''' </summary>
        Public Shared ReadOnly FontSizeProperty As DependencyProperty = DependencyProperty.Register("FontSize", GetType(Double), GetType(Ruler), New FrameworkPropertyMetadata(CDbl(16.0), FrameworkPropertyMetadataOptions.AffectsRender))

        ''' <summary>
        ''' Gets or sets the size of the chars in the ruler.
        ''' </summary><ComponentModel.Category("PropertyTabName")><ComponentModel.Description("DescriptionToolTip")>
        Public Property FontSize() As Double
            Get
                Return DirectCast(GetValue(FontSizeProperty), Double)
            End Get
            Set
                SetValue(FontSizeProperty, Value)
            End Set
        End Property
Any suggestions onhow to do?

Calendar NOT losing focus WPF 4.0

$
0
0

I have a WPF 4.0 Calendar control (Selection Mode: MultipleRange) and a button in a grid.

After selecting dates in the calendar, when I click on the button, the calendar is not losing its focus.  i.e., It leads me to click twice on the button to fire the button_click event.

Is that a known bug? I binged my level best but not finding any answer. I will appreciate if someone could solve it.

Thank you.

 


sgrajan

Change ListView Background color

$
0
0

Hi,

I have a WPF form which contains a ListView, and in design view the Background is "White" - see below extracted. I would like to dynamically change the background to other color, such asLightBlue.

        <ScrollViewer Margin="0,0,6,0" x:Name="ScrollViewer1" >
            <ListView x:Name="photobox" Background="White">
                <Border Margin="5" BorderThickness="1" Background="AliceBlue"   >

I tried the following code (VB.NET), but prompts an error. Can someone suggest the correct code example?

photobox.Background = Brushes.LightBlue

Thanks for your help!


Dotted Lines between nodes is not appearing in TreeView Item

$
0
0

Hi ,

In TreeView When i am adding a new Item,The Dotted lines between nodes is not showing  Dynamically.

(Kindly check the following  image)



When I restart my Execution,then it appears. 

Pls let me know whether i want to give any attributes in styles


Efforts may fail but don't fail to take effort -------------- sidd

can anybody help me?

$
0
0

hi

what's wrong in my code?

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
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 newapp
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }
        private void searchbingbutton_Click(object sender, RoutedEventArgs e)
        {
            SendToBing(false);
        }
        private void searchAsRSSButton_Click(object sender,  RoutedEventArgs e)
        {
            SendToBing(showAsRSS:true);
        }

        private void SendToBing(bool showAsRSS)
        {
            if (string.IsNullOrEmpty(searchText.Text))
            {
                MessageBox.Show("please enter a search term");
            }
        }
    }
}

wpf textbox

$
0
0
I need to keep the input inserted in several textbox when i reload the form..is it possible?

How to create an installer that updates from a website?

$
0
0

First of all, I am a structural engineer, not a real software developer. So, please don't kill me.

I'm developing a wpf software for my field.  I've created a website.  My software uses a couple of 3rd party components. 

(1) How do I create an installer that includes the 3rd party components all in a single installer executable? Because when I publish I get a bunch of files, including the 3rd party components.  How do I publish in a way that I only get 1 installer file?

(2) I found

http://autoupdaterdotnet.codeplex.com/ but I'm having a hard time figuring out how to use it. Basically, I want to be able to upload an update to my website and my program would automatically update the next time the user runs the application.  Please help?

WPF: Storyboard Completed event fires until it is completed.

$
0
0

Goal: To show a message, when Storyboard completes the animation.

Problem: It fires 1 step before it completes.

Question: How to show a message at the exact moment, when the animation completes?

Explanation:

It should show 30.

But it shows 29.******.

Code:

    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();

            this.Loaded += MainWindow_Loaded;
        }

        Line line;

        void MainWindow_Loaded(object sender, RoutedEventArgs e)
        {
            Canvas canvas = new Canvas();
            canvas.Background = Brushes.Black;
            this.Content = canvas;

            line = new Line();
            line.Stroke = Brushes.White;
            line.X1 = 0;
            line.Y1 = 0;
            line.X2 = 0;
            line.Y2 = 0;

            canvas.Children.Add(line);

            Animation();
        }

        private void Animation()
        {
            DoubleAnimation da = new DoubleAnimation();
            da.To = 30;
            da.Duration = TimeSpan.FromSeconds(1);

            Storyboard sb = new Storyboard();
            Storyboard.SetTarget(da, line);
            Storyboard.SetTargetProperty(da, new PropertyPath(Line.X2Property));
            sb.Children.Add(da);
            sb.Completed += delegate { MessageBox.Show(line.X2.ToString()); };
            sb.Begin();
        }
    }

Viewing all 18858 articles
Browse latest View live


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