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

'Provide value on 'System.Windows.StaticResourceExtension' threw an exception

$
0
0

Hi all,

I am completely new in WPF. i just started the "getting started" walkthrough.

I have successfully done all steps. My application crashed when i have done the first stpe which is the data binding with xml.

Basically i got the error :

'Provide value on 'System.Windows.StaticResourceExtension' threw an exception.' Line number '40' and line position '57'.

at the following code :

<ListBoxName="peopleListBox"Grid.Column="1"Grid.Row="2"ItemsSource="{Binding Source={StaticResource ExpenseDataSource}, XPath=Person}"ItemTemplate="{StaticResource nameItemTemplate}"></ListBox>

I have read this article :

http://connect.microsoft.com/VisualStudio/feedback/details/568346/wpf-error-message-when-there-is-a-style-only-in-app-xaml-and-application-onstartup-is-overridden

It did not help me to ifx the issue ?

What could be the fix ?

Thanks

PS : I am using VS 2010


[WPF] Can OnRender render if a Control is not added as child?

$
0
0

Question: Can OnRender render if a Control is not added to Canvas.Children as child?

Note: It renders if to use VisualCollection without a need to add Control to Canvas as child.

Code:

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

            Canvas canvas = new Canvas();
            this.Content = canvas;
            canvas.Background = Brushes.Black;

            MyImage myimage = new MyImage();
            myimage.InvalidateMeasure();
            myimage.InvalidateArrange();
            myimage.InvalidateVisual();
            myimage.UpdateLayout();

            //canvas.Children.Add(myimage); // Works

            canvas.MouseDown += delegate
            {
                RenderTargetBitmap target = new RenderTargetBitmap(100, 100, 96, 96, PixelFormats.Default);
                target.Render(myimage);

                ImageBrush brush = new ImageBrush();
                brush.ImageSource = target;
                canvas.Background = brush;
            };

        }
    }

    class MyImage : Image
    {
        protected override void OnRender(DrawingContext dc)
        {
            base.OnRender(dc);

            dc.DrawRectangle(Brushes.Red, null, new Rect(0, 0, 100, 100));
        }
    }

[WPF] How to set Image.Source drawn by OnRender to ImageBrush.ImageSource?

$
0
0

Goal:

1. Create MyImage : Image and override OnRender.

2. Set Myimage.Source to ImageBrush.ImageSource.

3. Set ImageBrush.ImageSource to Canvas.Background.

Problem: It draws transparent, but not what OnRender draws.

Notes:

1. It works, if to set an image via a link.

2. I need to draw by Brush, other options are not valid.

Code:

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

            Canvas canvas = new Canvas();
            this.Content = canvas;
            canvas.Background = Brushes.Black;

            MyImage myimage = new MyImage();
            myimage.InvalidateVisual();

            ImageBrush brush = new ImageBrush();
            brush.ImageSource = myimage.Source;
            canvas.Background = brush;
        }
    }

    class MyImage : Image
    {
        protected override void OnRender(DrawingContext dc)
        {
            base.OnRender(dc);

            dc.DrawRectangle(Brushes.Red, null, new Rect(0, 0, 100, 100));
        }
    }

Word and PDF file rights management

$
0
0

can we manage MS word or PDF file right that are opened in my WPF-Application. Mean user that login into my application is a super user that have right to edit and view that particular file and the other user that have only view rights. 

Example:

Word file name abc.docx stored in my DB.

user1 have (View, Edit, delete, add) rights.

user2 has(View) rights.

list of files display in WPF datagrid. when user2 click on one particular file then that particular file opened but application not allow this user to make changes in this document. user2 only view this file.

Waiting for your replies

Follow-up question on a potentially corrupt project file

$
0
0

Last week I posted a question on these forums, Why can't we create a resource dictionary?. I believe that question was answered.

But I've got a follow-up question. I'm at work now and am looking at the project file, which I'll include below. At first I thought that issue might be that he had created the project as a Windows Forms project and just added some XAML files to it, but now I'm not so sure. I created 2 dummy projects, one Windows Forms and the other a WPF project, and both have a key in the first PropertyGroup that reads as follows:

<OutputType>WinExe</OutputType>

So I don't know what distinguishes a Windows Forms project from a WPF project, at least as far as the .csproj file goes. What does?

Another thing that is odd about this project is that there is no solution file. I'm not sure why there isn't, but there isn't. Could the type of project be stored in the .sln file?

Here's the text of the .csproj file that seems to be messed up:

<?xml version="1.0" encoding="utf-8"?><Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"><PropertyGroup><Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration><Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform><ProductVersion>8.0.30703</ProductVersion><SchemaVersion>2.0</SchemaVersion><ProjectGuid>{11B8E4CB-C35C-4059-97DB-DD1CE6105F65}</ProjectGuid><OutputType>WinExe</OutputType><AppDesignerFolder>Properties</AppDesignerFolder><RootNamespace>TestBed</RootNamespace><AssemblyName>TestBed</AssemblyName><TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion><FileAlignment>512</FileAlignment><SccProjectName>SAK</SccProjectName><SccLocalPath>SAK</SccLocalPath><SccAuxPath>SAK</SccAuxPath><SccProvider>SAK</SccProvider></PropertyGroup><PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "><DebugSymbols>true</DebugSymbols><DebugType>full</DebugType><Optimize>false</Optimize><OutputPath>bin\Debug\</OutputPath><DefineConstants>DEBUG;TRACE</DefineConstants><ErrorReport>prompt</ErrorReport><WarningLevel>4</WarningLevel></PropertyGroup><PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "><DebugType>pdbonly</DebugType><Optimize>true</Optimize><OutputPath>bin\Release\</OutputPath><DefineConstants>TRACE</DefineConstants><ErrorReport>prompt</ErrorReport><WarningLevel>4</WarningLevel></PropertyGroup><ItemGroup><Reference Include="FirstFloor.ModernUI, Version=1.0.6.0, Culture=neutral, PublicKeyToken=2d21ec3cd074c59a, processorArchitecture=MSIL"><HintPath>packages\ModernUI.WPF.1.0.6\lib\net45\FirstFloor.ModernUI.dll</HintPath><Private>True</Private></Reference><Reference Include="System" /><Reference Include="System.Data" /><Reference Include="System.Xml" /><Reference Include="Microsoft.CSharp" /><Reference Include="System.Core" /><Reference Include="System.Xml.Linq" /><Reference Include="System.Data.DataSetExtensions" /><Reference Include="System.Xaml"><RequiredTargetFramework>4.0</RequiredTargetFramework></Reference><Reference Include="WindowsBase" /><Reference Include="PresentationCore" /><Reference Include="PresentationFramework" /></ItemGroup><ItemGroup><ApplicationDefinition Include="App.xaml"><Generator>MSBuild:Compile</Generator><SubType>Designer</SubType></ApplicationDefinition><Compile Include="App.xaml.cs"><DependentUpon>App.xaml</DependentUpon><SubType>Code</SubType></Compile><Page Include="MainWindow.xaml"><Generator>MSBuild:Compile</Generator><SubType>Designer</SubType></Page><Compile Include="MainWindow.xaml.cs"><DependentUpon>MainWindow.xaml</DependentUpon><SubType>Code</SubType></Compile><Page Include="Pages\Settings\About.xaml"><SubType>Designer</SubType><Generator>MSBuild:Compile</Generator></Page><Compile Include="Model\CoreTileModel.cs" /><Compile Include="Model\ObservableObject.cs" /><Compile Include="ViewModel\CoreTileViewModel.cs" /><Compile Include="Pages\Settings\About.xaml.cs"><DependentUpon>About.xaml</DependentUpon></Compile><Page Include="Pages\Settings\Appearance.xaml"><SubType>Designer</SubType><Generator>MSBuild:Compile</Generator></Page><Compile Include="Pages\Settings\Appearance.xaml.cs"><DependentUpon>Appearance.xaml</DependentUpon></Compile><Compile Include="Pages\Settings\AppearanceViewModel.cs" /><Page Include="Pages\Home.xaml"><SubType>Designer</SubType><Generator>MSBuild:Compile</Generator></Page><Page Include="Pages\SettingsPage.xaml"><SubType>Designer</SubType><Generator>MSBuild:Compile</Generator></Page><Compile Include="Pages\Home.xaml.cs"><DependentUpon>Home.xaml</DependentUpon></Compile><Compile Include="Pages\SettingsPage.xaml.cs"><DependentUpon>SettingsPage.xaml</DependentUpon></Compile><Compile Include="Properties\AssemblyInfo.cs" /></ItemGroup><ItemGroup><None Include="packages.config" /></ItemGroup><ItemGroup><Folder Include="Generic\" /></ItemGroup><Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /><!-- To modify your build process, add your task inside one of the targets below and uncomment it.
       Other similar extension points exist, see Microsoft.Common.targets.<Target Name="BeforeBuild"></Target><Target Name="AfterBuild"></Target>
  --></Project>


Rod

Get the Profiler to run the Acceptance tests are being executed so that Onscreen performance can be measure?

$
0
0

Hi,

I am working on an ongoing project most of those code is not from me and doesn't support Unit Testing. Each block of code consist of several lines of code. Each file consist of more than 1,000 lines of code.

I have to write UIAutomation Test against those code.

Following is my Goal:

Get the Profiler to run the Acceptance tests are being executed so that Onscreen performance can be measure?

How to achieve this in code? I don't have any problem with Acceptance tests!.

Thanks,

Weera

agent westinghouse الوحيد في صيانة ثلاجات وستنجهاوس 01154008110 (مصر الجديدة ) 0235699066

$
0
0

المركز الرئيسى صيانة وكيلagentصيانة وستنجهاوس وكيلagentصيانة وستنجهاوس  صيانة الاجهزة المنزلية ونتعهد بالضمان والجودة( ثلاجات,غسالات, دراير ,لاندري, غسالات اطباق , ايس ميكر ، ديب فريزر , تكييفات )

01223179993 //01154008110 //01223179993

0235710008/0235699066

مركزتوكيلagentصيانة وكيل agentصيانة وستنجهاوس وكيل agentصيانة وستنجهاوس المعتمد1.صيانة توكيل agentغسالات وكيل agentصيانة وستنجهاوس وكيل agentصيانة وستنجهاوس2.صيانة توكيل agentثلاجات وكيل agentصيانة وستنجهاوس وكيل agentصيانة وستنجهاوس3.صيانة توكيل agentتكيفات وكيل agentصيانة وستنجهاوس وكيل agentصيانة وستنجهاوس4.صيانة توكيل agentايس ميكر وكيل agentصيانة وستنجهاوس وكيل agentصيانة وستنجهاوس5.صياتة توكيل agentدراير وكيل agentصيانة وستنجهاوس وكيل agentصيانة وستنجهاوستوكيل agentجميع اجهزة وكيل agentصيانة وستنجهاوس وكيل agentصيانة وستنجهاوس الامريكية والايطالية توكيل agentشركة وكيل agentصيانة وستنجهاوس وكيل agentصيانة وستنجهاوس العالمية صيانة الاجهزة المنزلية35710008//01223179993 //01154008110 //

0235710008 // 0235699066

 ضمان لمدة عام كامل و متابعة مستمرة كل ثلاث شهور  , اصلاح اشهر الماركات العالمية الامريكية و الايطالية و المانية اصلاح فى مقر العميل.

agent westinghouse الوحيد في صيانة ثلاجات وستنجهاوس 01154008110 (مصر الجديدة ) 0235699066

$
0
0

المركز الرئيسى صيانة وكيلagentصيانة وستنجهاوس وكيلagentصيانة وستنجهاوس  صيانة الاجهزة المنزلية ونتعهد بالضمان والجودة( ثلاجات,غسالات, دراير ,لاندري, غسالات اطباق , ايس ميكر ، ديب فريزر , تكييفات )

01223179993 //01154008110 //01223179993

0235710008/0235699066

مركزتوكيلagentصيانة وكيل agentصيانة وستنجهاوس وكيل agentصيانة وستنجهاوس المعتمد1.صيانة توكيل agentغسالات وكيل agentصيانة وستنجهاوس وكيل agentصيانة وستنجهاوس2.صيانة توكيل agentثلاجات وكيل agentصيانة وستنجهاوس وكيل agentصيانة وستنجهاوس3.صيانة توكيل agentتكيفات وكيل agentصيانة وستنجهاوس وكيل agentصيانة وستنجهاوس4.صيانة توكيل agentايس ميكر وكيل agentصيانة وستنجهاوس وكيل agentصيانة وستنجهاوس5.صياتة توكيل agentدراير وكيل agentصيانة وستنجهاوس وكيل agentصيانة وستنجهاوستوكيل agentجميع اجهزة وكيل agentصيانة وستنجهاوس وكيل agentصيانة وستنجهاوس الامريكية والايطالية توكيل agentشركة وكيل agentصيانة وستنجهاوس وكيل agentصيانة وستنجهاوس العالمية صيانة الاجهزة المنزلية35710008//01223179993 //01154008110 //

0235710008 // 0235699066

 ضمان لمدة عام كامل و متابعة مستمرة كل ثلاث شهور  , اصلاح اشهر الماركات العالمية الامريكية و الايطالية و المانية اصلاح فى مقر العميل.


Password Box Event button event C# WPF

$
0
0

when a button is clicked it used _click event in C# code

what is the event for a password box in C# wpf visual studio that executes when enter is pressed?
private void PasswordInput_?(object sender, EventArgs e)
{
MessageBox.Show("");
}

"WindowsFormsHost in wpf with Prism not loading windows controls properly"

$
0
0

Hello,

I'm working on prism 5.0 framework with .net 4.5 framework and using visual studio 2013.

In my application I'm trying to load windows controls say "Button" or any other windows controls I'm not able to load them in wpf view where my wpf view is a usercontrol.

I tried loading other control, I could only see "Tooltip" appearing for those controls but I see my needed controls are not getting loaded in place.

Example: I'm trying to load UltraLivewTileView here

snippet :

   WindowsFormsHost host = new WindowsFormsHost();
            host.BringIntoView();
            host.Child = liveTileView2;
            try
            {
                this.liveGroup.Content = host;
            }
            catch (Exception ex)
            {
            }

where "liveGroup" is groupbox. 

I tried working on sample of wpf window loading  windowsforms controls on it, works fine.But looks like in application development this issue appearing. I did compare all references with sample application and tried for work around but did not get any help.

My View is a usercontrol and I did try changing it to window and see AllowTransperecny is false and Windowstate is set to normal.But in both of these cases my required controls are not getting loaded/not visible. In user control only I can see is tooltip for the controls loaded.

Can any one has came across such issues?

Please provide inputs for resolving this is issue.

Thanks,

Shesh


Mouse scroll zoom operation not working in wpf map.

$
0
0
I am developing an windows forms application and integrating WPF map control inside windows form using WindowsFormsHost control. But when the form loaded the map also loaded but the map zoom in & zoom out on mouse scroll event not working.

does not exist in the namespace

$
0
0

I have the following code in App.xaml:

<Application x:Class="eesPhotography.App"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:u="clr-namespace:eesUtilities"
             xmlns:local="clr-namespace:eesPhotography"
             StartupUri="MainWindow.xaml"><Application.Resources><u:DateConverter x:Key="DateConverter"/>

When I typed in 'u:' intellisense displayed DateConverter, which I selected and then completed the code. However, it's displaying this message when the mouse hovers over the code:

The name DateConverter does not exist in the namespace 'clr-namespace:Utilities'

What am I doing wrong?

This is the class I'm referencing:

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.Globalization;

namespace eesUtilities
{
    class CustomAttachedProperties
    {
        public static readonly DependencyProperty ShowNullWhenDateTimeMinValueProperty =
                    DependencyProperty.RegisterAttached("ShowNullWhenDateTimeMinValue",
                                       typeof(bool),
                                       typeof(CustomAttachedProperties),
                                       new PropertyMetadata(default(bool),
                                       SetShowNullWhenDateTimeMinValueChanged));

        private static void SetShowNullWhenDateTimeMinValueChanged(DependencyObject d,
                                               DependencyPropertyChangedEventArgs e)
        {
            DatePicker control = (DatePicker)d;
            if ((bool)e.NewValue)
            {
                control.SelectedDateChanged += OnSelectedDateChanged;
            }
            else
            {
                control.SelectedDateChanged -= OnSelectedDateChanged;
            }
        }

        public static void SetShowNullWhenDateTimeMinValue(UIElement element, bool value)
        {
            element.SetValue(ShowNullWhenDateTimeMinValueProperty, value);
        }

        private static void OnSelectedDateChanged(object sender, SelectionChangedEventArgs e)
        {
            UIElement control = (UIElement)sender;

            if ((bool)control.GetValue(ShowNullWhenDateTimeMinValueProperty))
            {
                var currentSelectedDate = ((DateTime?)control.GetValue(DatePicker.SelectedDateProperty));
                if (currentSelectedDate.HasValue && currentSelectedDate.Value == DateTime.MinValue)
                {
                    //currently set DateTime.Now that the DatePicker opens the Popup with the current month
                    control.SetValue(DatePicker.SelectedDateProperty, DateTime.Now);
                    control.SetValue(DatePicker.SelectedDateProperty, null);
                }
            }
        }

        public static bool GetShowNullWhenDateTimeMinValue(UIElement element)
        {
            return (bool)element.GetValue(ShowNullWhenDateTimeMinValueProperty);
        }

    }

    public class DateConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value != null)
                return ((DateTime)value).ToShortDateString();
            return String.Empty;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            string strValue = value.ToString();
            DateTime resultDateTime;
            return DateTime.TryParse(strValue, out resultDateTime) ? resultDateTime : value;
        }
    }

}

XAML XBAP Favicons

$
0
0

I was asked to add an favicons to my xbap browser applications, although I have added the .ico file as a Resource under the property page of the project, how would I add this favicon to the xbap applicaton so that it show up to left of the http:// in the url?

How to IsEnabled property of button with textbox, combobox and two radio options? using Multibinding and iMultivalueconverter?

$
0
0

Hi,

I am stuck in multibinding and imultivalueconverter..

I am using IMultiValueConverter to convert value.

I have 1 button which I want to Enable Disable depending on textbox has text, combobox has selectedindex and anyone radio button checked from two radio button.

my problem is that when i select the male radio button then button is enable and when i select the female radio button then button is disable..

i want to  enable button when textbox has text, combobox has selected index and anyone radio button is checked from male and female radio button.

Converter:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.ComponentModel;
using System.Windows.Data;
using System.Globalization;

namespace WpfApplication4
{
    public class FormFilledMultiConverter:IMultiValueConverter
    {      
        public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
        {
            string name = values[0].ToString();
            int selectedIndex = (int)values[1];
            bool check = (bool)values[2];
            bool isCheck = (bool)values[3];
            return name.Length > 0 && selectedIndex != -1 && check || isCheck;
        }
        public object[] ConvertBack(object value, Type[] targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}

XAML :

<Window x:Class="WpfApplication4.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="clr-namespace:WpfApplication4"
        Title="MainWindow" Height="350" Width="525">
    <Window.Resources>
        <local:FormFilledMultiConverter x:Key="FormFilledMultiConverter"/>
    </Window.Resources>
    <Grid>
        <Label x:Name="labelName" Content="Name:" Margin="128,64,335,214"/>
        <TextBox x:Name="textBoxName" Margin="204,64,164,231"/>
        <Label x:Name="labelLetter" Content="Letter:" VerticalAlignment="Center" Margin="128,110,318,178" Height="31"/>
        <ComboBox x:Name="comboBoxLetter" Margin="204,110,164,183" RenderTransformOrigin="1.706,1.583">
            <ComboBoxItem Content="Alpha"/>
            <ComboBoxItem Content="Beta"/>
            <ComboBoxItem Content="Delta"/>
            <ComboBoxItem Content="Gamma"/>
        </ComboBox>
        <Label Content="Gender" Width="57" HorizontalAlignment="Left" Margin="128,155,0,127"/>
        <RadioButton GroupName="group" x:Name="rbtMale" Content="Male" Margin="204,166,252,127"/>
        <RadioButton GroupName="group" x:Name="rbtFemale" Content="Female" Width="66" Margin="204,197,247,96"/>
        <Button x:Name="buttonSubmit" Content="Submit" Margin="204,244,199,25">
            <Button.IsEnabled>
                <MultiBinding Converter="{StaticResource FormFilledMultiConverter}">
                    <Binding Path="Text" ElementName="textBoxName"/>
                    <Binding Path="SelectedIndex" ElementName="comboBoxLetter"/>
                    <Binding Path="IsChecked" ElementName="rbtMale"/>
                    <Binding Path="IsChecked" ElementName="rbtFemale"/>
                </MultiBinding>
            </Button.IsEnabled>
        </Button>
    </Grid>
</Window>


How to enabled property of button with teextbox, combobox and two radiobutton options?? with multibinding and imultivalueconverter ??

$
0
0

I m stuck in multi binding and imultivalueconverter

I am using IMultiValueConverter to convert value.

I have 1 button which I want to Enable depending on this textbox has text, combobox is selected index and anyone radio button is checked from two radio button.

but when i select the male radiobutton then button is enable and when i select the female radio button then radiobutton is disable
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.ComponentModel;
using System.Windows.Data;
using System.Globalization;

namespace WpfApplication4
{
    public class FormFilledMultiConverter:IMultiValueConverter
    {
        public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
        {
            string name = values[0].ToString();
            int selectedIndex = (int)values[1];
            bool check = (bool)values[2];
            return name.Length > 0 && selectedIndex != -1 || check;

        public object[] ConvertBack(object value, Type[] targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}

xaml:

<Window x:Class="WpfApplication4.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="clr-namespace:WpfApplication4"
        Title="MainWindow" Height="350" Width="525"><Window.Resources><local:FormFilledMultiConverter x:Key="FormFilledMultiConverter"/></Window.Resources><Grid><Label x:Name="labelName" Content="Name:" Margin="128,64,335,214"/><TextBox x:Name="textBoxName" Margin="204,64,164,231"/><Label x:Name="labelLetter" Content="Letter:" VerticalAlignment="Center" Margin="128,110,318,178" Height="31"/><ComboBox x:Name="comboBoxLetter" Margin="204,110,164,183" RenderTransformOrigin="1.706,1.583"><ComboBoxItem Content="Alpha"/><ComboBoxItem Content="Beta"/><ComboBoxItem Content="Delta"/><ComboBoxItem Content="Gamma"/></ComboBox><Label Content="Gender" Width="57" HorizontalAlignment="Left" Margin="128,155,0,127"/><RadioButton GroupName="group" x:Name="rbtMale" Content="Male" Margin="204,166,252,127"/><RadioButton GroupName="group" x:Name="rbtFemale" Content="Female" Width="66" Margin="204,197,247,96"/><Button x:Name="buttonSubmit" Content="Submit" Margin="204,244,199,25"><Button.IsEnabled><MultiBinding Converter="{StaticResource FormFilledMultiConverter}"><Binding Path="Text" ElementName="textBoxName"/><Binding Path="SelectedIndex" ElementName="comboBoxLetter"/><Binding Path="IsChecked" ElementName="rbtMale"/><Binding Path="IsChecked" ElementName="rbtFemale"/></MultiBinding></Button.IsEnabled></Button></Grid></Window>



RoutedEventHandler GotFocus

$
0
0
RoutedEventHandler GotFocus of WPF UserControl not fire on windows 7 32 bit, the framework is: .net framework 4.
Any idea how to overcome this problem?

Thanks,

tomer trojman

WPF c# I i place my cursor in a richtextbox next to a letter fontsize 14 I wanted some code to change the combobox to value 14

$
0
0
WPF c# I i place my cursor in a richtextbox next to a letter fontsize 14 I wanted some code to change the combobox to value 14

WPF / C#

$
0
0

Hello everyone,

I`m starting to learn WPF in visual studio.

My question is related to class declarations in XAML when creating a new project in WPF,

I see:

<Window x:Class="WpfApplication1.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"><Grid></Grid></Window>

I understand that these are URIs, my question is related to the URI/URLs declared in the code "

schemas.microsoft.com

"

How XAML uses those URLs and when does it needs to access to those URLs address, internet connection needed?

Shouldn`t these be local paths? or Use URNs instead of URLS?

WPF c# code prints in two columns how do i make this code for a normal page.

$
0
0
 public static int SaveAsXps(string fileName)
        {

            object doc;



            FileInfo fileInfo = new FileInfo(fileName);



            using (FileStream file = fileInfo.OpenRead())
            {

                System.Windows.Markup.ParserContext context = new System.Windows.Markup.ParserContext();

                context.BaseUri = new Uri(fileInfo.FullName, UriKind.Absolute);

                doc = System.Windows.Markup.XamlReader.Load(file, context);

            }



            if (!(doc is IDocumentPaginatorSource))
            {

                Console.WriteLine("DocumentPaginatorSource expected");

                return -1;

            }



            using (Package container = Package.Open(fileName + ".xps", FileMode.Create))
            {

                using (XpsDocument xpsDoc = new XpsDocument(container, CompressionOption.Maximum))
                {

                    XpsSerializationManager rsm = new XpsSerializationManager(new XpsPackagingPolicy(xpsDoc), false);



                    DocumentPaginator paginator = ((IDocumentPaginatorSource)doc).DocumentPaginator;



                    // 8 inch x 6 inch, with half inch margin

                  //  paginator = new DocumentPaginatorWrapper(paginator, new Size(768, 676), new Size(48, 48));
                    paginator = new DocumentPaginatorWrapper(paginator, new Size(768, 676), new Size(0, 0));
                     try
                    {

                    rsm.SaveAsXaml(paginator);
                     }
                     catch (Exception ex)
                     {
                         // just in case, do something
                     }
                }

            }



            Console.WriteLine("{0} generated.", fileName + ".xps");



            return 0;

        }


public class DocumentPaginatorWrapper : DocumentPaginator

{

    Size              m_PageSize;

    Size              m_Margin;

    DocumentPaginator m_Paginator;

    Typeface          m_Typeface;



    public DocumentPaginatorWrapper(DocumentPaginator paginator, Size pageSize, Size margin)

    {

        m_PageSize  = pageSize;

        m_Margin    = margin;

        m_Paginator = paginator;



        m_Paginator.PageSize = new Size(m_PageSize.Width  - margin.Width  * 2,

                                        m_PageSize.Height - margin.Height * 2);

    }



    Rect Move(Rect rect)

    {

        if (rect.IsEmpty)

        {

            return rect;

        }

        else

        {

            return new Rect(rect.Left + m_Margin.Width, rect.Top + m_Margin.Height,

                            rect.Width, rect.Height);

        }

    }



    public override DocumentPage GetPage(int pageNumber)

    {

        DocumentPage page = m_Paginator.GetPage(pageNumber);



        // Create a wrapper visual for transformation and add extras

        ContainerVisual newpage = new ContainerVisual();



        DrawingVisual title = new DrawingVisual();



        using (DrawingContext ctx = title.RenderOpen())

        {

            if (m_Typeface == null)

            {

                m_Typeface = new Typeface("Times New Roman");

            }



            FormattedText text = new FormattedText("Page " + (pageNumber + 1),

                System.Globalization.CultureInfo.CurrentCulture, FlowDirection.LeftToRight,

                m_Typeface, 14, Brushes.Black);



            ctx.DrawText(text, new Point(0, -96 / 4)); // 1/4 inch above page content

        }



        DrawingVisual background = new DrawingVisual();



        using (DrawingContext ctx = background.RenderOpen())

        {

            ctx.DrawRectangle(new SolidColorBrush(Color.FromRgb(240, 240, 240)), null, page.ContentBox);

        }



        newpage.Children.Add(background); // Scale down page and center



            ContainerVisual smallerPage = new ContainerVisual();

            smallerPage.Children.Add(page.Visual);

            smallerPage.Transform = new MatrixTransform(0.95, 0, 0, 0.95,

                0.025 * page.ContentBox.Width, 0.025 * page.ContentBox.Height);



        newpage.Children.Add(smallerPage);

        newpage.Children.Add(title);



        newpage.Transform = new TranslateTransform(m_Margin.Width, m_Margin.Height);



        return new DocumentPage(newpage, m_PageSize, Move(page.BleedBox), Move(page.ContentBox));

    }



    public override bool IsPageCountValid

    {

        get

        {

            return m_Paginator.IsPageCountValid;

        }

    }



    public override int PageCount

    {

        get

        {

            return m_Paginator.PageCount;

        }

    }



    public override Size PageSize

    {

        get

        {

            return m_Paginator.PageSize;

        }



        set

        {

            m_Paginator.PageSize = value;

        }

    }



    public override IDocumentPaginatorSource Source

    {

        get

        {

            return m_Paginator.Source;

        }

    }

}

MainWindowHandle is 0(Zero)?

$
0
0

Hi,

I would like to get MainWindowHandle. I works for almost all WPF app but except the one that I am working with.

try
            {
                ProcessStartInfo startInfo = new ProcessStartInfo(applicationName);
                startInfo.WorkingDirectory = Path.GetDirectoryName(applicationName);
                startInfo.UseShellExecute = false;

                targetProcess = Process.Start(startInfo);

                Thread.Sleep(12000);

                targetProcess.Refresh();
                AutomationElement aeWindow = AutomationElement.FromHandle(targetProcess.Handle);
                StateDiagnosis.Instance.StopDiagnosis(this);
                aeList.Add(aeWindow);
                return aeList;
            }
            catch (Exception)
            {
                UnloadApp(targetProcess);
                return null;
            }

The following line it Zero.

targetProcess.Handle

How to find the MainWindowHandle? is there other way? It is Tray app + WPF.

Thanks,

Weera

Viewing all 18858 articles
Browse latest View live


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