|
Pete is correct here.
modified 27-Feb-21 21:01pm.
|
|
|
|
|
That's not really using two styles on a control though is it? It's just basing one style on another style as far as I can tell.
|
|
|
|
|
True - that's why I said you had to create a new style. There's no way round this as you noted earlier.
|
|
|
|
|
|
And to clarify the point, I 5d your answer above. That should make it plain for the OP.
|
|
|
|
|
I've not actually used the BasedOn approach to a styles yet. Could prove interesting to see how it actually works.
|
|
|
|
|
I use it a lot - it's incredibly useful.
|
|
|
|
|
Hello,
I am still having a trouble cropping with my project I am trying to create, which I have included the code and the XAML code below. For my project, i am trying to have the user click on the button "crop image" then they are given the ability to highlight the area to crop, and right click and save the crop image as jpg or bmp, so far i have looked at several examples including jim's input (thank you jim again) but still is a little confusing to me, if someone can help me out with this by completing the missing piece (or finishing the project), and/or explain that would be great. I am willing to go even as far as talking over the phone or email just to help me because i feel this is an essential thing to learn using WPF/C# image object/bitmap. If anyone can help me out with this one i would be very very grateful. So again, the code is below so you can see what i got so far, which i like because you can zoom in and out of the image object called viewerphoto1 using the slider. Anyways here is the code below:
XAML:
<Window x:Class="WPFcropimage.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="370" Width="591">
<Grid Height="341" Width="595">
<DockPanel Margin="23,33,181,29">
<Slider x:Name="Zoom" DockPanel.Dock="Left" Value="1" Minimum="0.1" Maximum="5" Width="25" Orientation="Vertical" ValueChanged="Zoom_ValueChanged" />
<ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" Height="270" Width="356">
<Image Stretch="Uniform" Height="262" Width="349" Name="_viewedPhoto1">
<Image.LayoutTransform>
<ScaleTransform ScaleX="{Binding ElementName=Zoom,Path=Value}" ScaleY="{Binding ElementName=Zoom,Path=Value}"/>
</Image.LayoutTransform>
</Image>
</ScrollViewer>
</DockPanel>
<Button Height="38" HorizontalAlignment="Right" Margin="0,33,41,0" Name="_btnbrowse" VerticalAlignment="Top" Width="104" Click="_btnbrowse_Click">Browse for Picture</Button>
<Button Height="38" HorizontalAlignment="Right" Margin="0,89,41,0" Name="_btnCrop" VerticalAlignment="Top" Width="104" Click="_btnCrop_Click">Crop Picture</Button>
<Button Height="37" HorizontalAlignment="Right" Margin="0,0,41,33.5" Name="_btnClose" VerticalAlignment="Bottom" Width="104" Click="_btnClose_Click">Close</Button>
<Border Margin="53,37.5,187,33.5" Name="_border1" BorderBrush="Black" BorderThickness="2">
</Border>
</Grid>
</Window>
C# code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Forms;
using System.Drawing.Imaging;
using System.Drawing;
namespace WPFcropimage
{
/// <summary>
/// Interaction logic for Window1.xaml
/// </summary>
public partial class Window1 : Window
{
public Window1()
{
InitializeComponent();
}
private void _btnbrowse_Click(object sender, RoutedEventArgs e)
{
OpenFileDialog dlg = new OpenFileDialog();
dlg.InitialDirectory ="c:\\";
dlg.Filter =
"Image files (*.jpg)|*.jpg|*.bmp)|*.bmp|All Files (*.*)|*.*";
dlg.RestoreDirectory =
true;
if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
string selectedFileName = dlg.FileName;
BitmapImage bitmap = new BitmapImage();
bitmap.BeginInit();
bitmap.UriSource =
new Uri(selectedFileName);
bitmap.EndInit();
_viewedPhoto1.Source = bitmap;
}
}
private void _btnClose_Click(object sender, RoutedEventArgs e)
{
this.Close();
}
private void Zoom_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
{
}
private void _btnCrop_Click(object sender, RoutedEventArgs e)
{
}
}
}
|
|
|
|
|
Hey everyone,
I was looking at this example from the link below, which i like, i am trying to have the user click on the button crop image, and thats when it will show the rectangle, however the description or the explanation is sorta hard to understand, can anyone help me with this, including how to get crop image to appear on the crop image viewer object?
thanks
link:
http://www.codeproject.com/KB/WPF/CropAdorner.aspx[^]
|
|
|
|
|
Using VS2008 Standard on XP/64:
I'm trying to do my first WPF app, and the IDE seems to have lost the ability to show properties for any control. The only way to fix it is to shut the IDE down and restart it, and then, it only works for the first control you try to view the properties for. What a POS...
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Wait, you were using the IDE? That's your problem, everybody knows that you shouldn't use XAML never mind the IDE, just use C#.
|
|
|
|
|
Did I miss something? Is there question here or just a rant?
only two letters away from being an asset
|
|
|
|
|
Looks like soapbox material to me!
Or maybe the MS complaint department redirects to here...
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi,
I created a UserControl in XAML that includes a Frame. But when the application is loading the Frame source, the application throws and InvalidOperationException. This message tells me, that the class for the Frame's source couldn't be found in the given namespace. And this is true, because it doesn't use the namespace I intended. Here's a short example to illustrate the problem:
<UserControl
x:Class="foo.fooControl"
...>
<Frame Source="fooPage.xaml" />
</UserControl>
<Page
x:Class="foo.fooPage"
...>
...
</Page>
Now the application tries to find the class for fooPage in the wrong namespace, i.e. foo.fooControl.fooPage. But that's of course wrong, because it's called foo.fooPage.
Can anybody help me and show me the correct way to achieve what I want?
Thanks in advance,
Jammni+
|
|
|
|
|
Are you sure you didn't change the namespace in your code-behind?
This works fine for me:
<!-- UserControl1.xaml -->
<UserControl x:Class="WPFTester.UserControl1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Height="128" Width="200">
<Grid>
<Frame Name="frame1" Source="Page1.xaml" />
</Grid>
</UserControl>
<!-- Page1.xaml -->
<Page x:Class="WPFTester.Page1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Page1" Height="128" Width="200">
<Grid Background="SteelBlue"/>
</Page>
<!-- Window1.xaml -->
<Window x:Class="WPFTester.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:WPFTester"
Title="Window1" Height="300" Width="300">
<Grid>
<local:UserControl1></local:UserControl1>
</Grid>
</Window>
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Thanks for your answer. That's more or less exactly what I am doing. Only that I placed the files in some directories, so the namespace is a bit longer.
And I didn't change the namespace in the code behind files. The strange thing is, that the exception already says, that the class should be located in a different namespace - one, that doesn't make any sense to me.
Currently I load the page in the code behind file. Perhaps I get some time later this day and can break it down and post a "working" sample.
But anyway, thanks for your answer
|
|
|
|
|
Hi everybody.
In HTML we can use a written tag in somewhere of our page, with its ID and JavaScript . As you know something like this :
<script language="javascript" type="text/javascript">
var tag = document.getElementById('tagID');
var destinationTag = document.getElementById('destinationID');
destinationTag.innerHTML = tag.innerHTML;
</script>
Now I wanna do it with XAML and C#.
For example, I've already written this XAML code :
<Grid x:Name="tag">
<Rectangle Style="{DynamicResource RectangleStyleForHolydays}"/>
<TextBlock HorizontalAlignment="Center" VerticalAlignment="Center">
content
</TextBlock>
</Grid>
Then I wanna write this XAML code in a container like a Grid with C#
<Grid x:Name="destinationTag">
<!-- here -->
</Grid>
Is it possible ?
Any ideas ?
Thank you.
|
|
|
|
|
AFAIK you can't embed C# in XAML.
You can, however, create child elements of your "destinationTag"
Grid using C#....is that what you need to do?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Mark Salsbery wrote: is that what you need to do?
No, thanks I thought maybe we can do it like HTML and JavaScript.
BTW I didn't want embed C# in XAML , I've wanted to copy XAML codes with C# from a side XAML file to the other side of it.
Do u understand what I mean ?
modified on Saturday, December 27, 2008 1:27 PM
|
|
|
|
|
Actually, you can embed .NET language code within XAML by placing it within <x:code xmlns:x="#unknown"> tags. Such code is moved into the generated partial class by the compiler, and the language must match the language of the containing project (i.e. you can't embed C# in a VB proj).
While I can't think of any good reason to do this, it is possible.
Keith
|
|
|
|
|
Thanks. I didn't know that
Have any examples (or links to examples)?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
<Button Click="button_Click">Ok</Button>
<x:Code><!CDATA[
void button_Click(object sender, RoutedEventArgs e)
{
this.Close();
}
]]></x:Code>
This example is taken from WPF Unleashed by Adam Nathan. Wrapping in CDATA is not required, but avoids the need to escape less-than, greater-than, and ampersand chars.
I am not aware of any links to more examples; probably because I can't think of any instance where coding in this manner would be a good idea.
Keith
P.S. Sorry about the formatting, couldn't figure out how to embed the XAML tags properly.
|
|
|
|
|
Thanks Keith. Much appreciated.
I just wanted to see what it looked like, and it really works!
Cheers,
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
|
Hi! I am a WPF beginner.
I just want to make an UI using WPF for an old unmanged Application coded by C++.
I want to using CCW(Com Callable Wrapper) between the managed and unmanaged world.
Following requirement is needed:
1. To keep the app unmanaged except UI;
2. To play video stream from the unmanaged app in WPF UI.
Best wishes for all and Merry chrismas!
Any help or hints are greatly appreciated!
Lance
|
|
|
|