|
Pete,
Appreciate the encouragement.
Enjoy and write some code!
modified 27-Feb-21 21:01pm.
|
|
|
|
|
Awesome! Thanks Karl!
Cheers,
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Mark,
Your welcome!
modified 27-Feb-21 21:01pm.
|
|
|
|
|
I have created a WPF Browser Application in VS2008. I've then added to XBAP to my webpage in a IFRAME
<iframe height="600" width="800" src="http://server/application/ClientBin/WPFApplication.xbap" />
This works fine, and displays the WPF. The problem is, IE never seems to clear its cache and get the latest XBAP once I've updated the WPF control. It always looks at the old control.
I've set my cache to always update every time I visit a page, and I've also cleared my history etc but it still looks at the old version.
Does anyone know how to solve this?
Regards,
Gareth.
(FKA gareth111)
|
|
|
|
|
Open up a Visual Studio Command Prompt, then run "mage -cc". Basically, as long as the version is the same it will probably not pull the updated version.
For more information go here[^]
Take care,
Tom
-----------------------------------------------
Check out my blog at http://tjoe.wordpress.com
|
|
|
|
|
Thanks, I already knew about this though.
Regards,
Gareth.
(FKA gareth111)
|
|
|
|
|
Hi,
I have a simple code snippet that changes the color of a background of a boder using animation. How to define that in style? I am getting the error message saying that I cannot specificy TargetName.
<Border.Background><br />
<SolidColorBrush x:Name="brush"></SolidColorBrush><br />
</Border.Background><br />
<Border.Triggers><br />
<EventTrigger RoutedEvent="Border.MouseEnter"><br />
<EventTrigger.Actions><br />
<BeginStoryboard><br />
<Storyboard><br />
<ColorAnimation Storyboard.TargetName="brush" Storyboard.TargetProperty="Color" To="Yellow" Duration="0:0:0.5"></ColorAnimation><br />
</Storyboard><br />
</BeginStoryboard><br />
</EventTrigger.Actions><br />
</EventTrigger><br />
<EventTrigger RoutedEvent="Border.MouseLeave"><br />
<EventTrigger.Actions><br />
<BeginStoryboard><br />
<Storyboard><br />
<ColorAnimation Storyboard.TargetName="brush" Storyboard.TargetProperty="Color" To="Transparent" Duration="0:0:0.5"></ColorAnimation><br />
</Storyboard><br />
</BeginStoryboard><br />
</EventTrigger.Actions><br />
</EventTrigger><br />
</Border.Triggers>
Thanks in advance for help
|
|
|
|
|
Style looks like this:
<style x:key="ButtonStyle" targettype="{x:Type Button}" xmlns:x="#unknown">
<setter property="Template">
<setter.value>
<controltemplate targettype="{x:Type Button}">
<controltemplate.resources>
<!-- Storyboards go here -->
</controltemplate.resources>
<grid>
<!-- Content goes here -->
</grid>
<controltemplate.triggers>
<!-- Triggers go here -->
</controltemplate.triggers>
</controltemplate>
</setter.value>
</setter>
</style>
You have to put everything in the appropriate place for it to work, then apply the style to the element you want
|
|
|
|
|
Thanks for reply! Is it possible to do that without defining a template? I believe that a simple style with 2 triggers would be enough
|
|
|
|
|
Yes. I think you can just ignore the "template" setter.. so just erase the <Setter Property="Template> and the <Setter.Value> stuff all the way until the </Setter> tag. I think you can just put a <Style.Resources> tag and put all the triggers in there... I think.... I haven't actually made any sample of this, but if that doesn't work I can always try to find a solution instead of doing my job lol
|
|
|
|
|
I thought the same and tried it, but it didn`t work. I got an error like I wrote in first post.
|
|
|
|
|
You can do
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Foreground" Value="{DynamicResource GenericButtonFontBrush}"/>
</Trigger>
</Style.Triggers>
|
|
|
|
|
Hello, I need to change content of Window2 in time. I use event to inform Window2 to change content and thread evoking event. To be easy, I only change content of Label in Window2 in time. Problem is, that content of Label isn´t changing when is thread sleeping and Windows "are not responding" and I don´t see anything in Windows 2. I see Label in Window2 only when my thread ends. I need to see Label with content "1", and in several seconds with content "2".... Could someone please have a look at my code and help me what I´m doing wrong?
App.xaml
<application x:class="WpfApplication1testtemplate.App" xmlns:x="#unknown">
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="Window1.xaml">
<application.resources>
</application.resources>
</application>
Window1.xaml
<window x:class="WpfApplication1testtemplate.Window1" xmlns:x="#unknown">
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="300" Width="300">
<grid>
<button height="23" horizontalalignment="Right" margin="0,105,27,0" name="button1" verticalalignment="Top" width="75" click="button1_Click">Start</button>
</grid>
</window>
Window1.xaml.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
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.Threading;
namespace WpfApplication1testtemplate
{
internal delegate void QueueListenerDelegate(Queue queue, MyArgumet args);
partial class Window1 : Window
{
Window2 w2;
public Window1()
{
InitializeComponent();
w2 = new Window2();
}
private void button1_Click(object sender, RoutedEventArgs e)
{
w2.Show();
Thread t = new Thread(new ThreadStart(Run));
t.SetApartmentState(ApartmentState.STA);
t.Start();
}
void Run()
{
this.Dispatcher.BeginInvoke(
DispatcherPriority.Send, (ThreadStart)delegate {
Queue queue = new Queue();
queue.NewItemAdded += new QueueListenerDelegate(w2.ListenAdd);
Random rand = new Random();
int d = 0;
queue.Add(d.ToString());
Thread.Sleep(2000);
d = 1;
queue.Add(d.ToString());
Thread.Sleep(2000);
d = 2;
queue.Add(d.ToString());
Thread.Sleep(2000);
queue.Add(d.ToString());
Thread.Sleep(2000);
d = 3;
queue.Add(d.ToString());
});
}}}
Window2.xaml
<window x:class="WpfApplication1testtemplate.Window2" xmlns:x="#unknown">
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window2" Height="300" Width="300">
<grid>
<dockpanel name="dockPanel1" />
</grid>
</window>
Window2.xaml.cs
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.Shapes;
namespace WpfApplication1testtemplate
{
partial class Window2 : Window
{
public Window2()
{
InitializeComponent();
myLabel = new Label();
}
public Label myLabel;
public int i = 0;
internal void ListenAdd(Queue queue, MyArgumet args)
{
if (i != 0) dockPanel1.Children.Remove(myLabel);
myLabel.Content = (String)args.AddedObject;
dockPanel1.Children.Add(myLabel);
i++;
}}}
Queue.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace WpfApplication1testtemplate
{
class Queue
{
public event QueueListenerDelegate NewItemAdded;
public Queue()
{
}
public void Add(string o)
{
if (NewItemAdded != null) NewItemAdded(this, new MyArgumet(o));
}}}
MyArgumet.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace WpfApplication1testtemplate
{
class MyArgumet : EventArgs
{
private object addedObject;
public object AddedObject
{
get { return addedObject; }
set { addedObject = value; }
}
public MyArgumet(object addedObject)
{
this.addedObject = addedObject;
}}}
|
|
|
|
|
Is there a reason that your architecture is so complicated? I can't see a lot of the code off to the side because of formatting issues here, but I can't see any reason why you need your code to be as complicated. Why not use an ObservableCollection if you need a collection of "changes"? If it's just updating a simple binding, take a look at using the DispatcherTimer.
Here's a simple object that uses the DispatcherTimer to update the time every second:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using System.Windows.Threading;
using System.Windows;
namespace MyNamespace
{
public class TimeManager : INotifyPropertyChanged, IDisposable
{
private DispatcherTimer _timer = null;
private string _currentDateAndTime;
public TimeManager(Window parent)
{
_timer = new DispatcherTimer(TimeSpan.FromSeconds(1), DispatcherPriority.Normal, new EventHandler(TimerTick), parent.Dispatcher);
}
protected virtual void TimerTick(object sender, EventArgs e)
{
CurrentDateAndTime = DateTime.Now.ToString();
}
protected virtual void Changed(string propertyName)
{
if (PropertyChanged != null)
{
PropertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));
}
}
public string CurrentDateAndTime
{
get
{
return _currentDateAndTime;
}
set
{
if (_currentDateAndTime != value)
{
_currentDateAndTime = value;
Changed("CurrentDateAndTime");
}
}
}
#region INotifyPropertyChanged Members
public event PropertyChangedEventHandler PropertyChanged;
#endregion
internal void Start()
{
if (_timer != null)
_timer.Start();
}
private void Stop()
{
if (_timer != null)
_timer.Stop();
}
#region IDisposable Members
public void Dispose()
{
Dispose(true);
}
private bool _disposed = false;
protected virtual void Dispose(bool dispose)
{
if (!_disposed && dispose)
{
Stop();
_disposed = true;
GC.SuppressFinalize(this);
}
}
#endregion
}
} Here's a status bar (UserControl) that makes use of it:
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;
namespace MyNamespace
{
public partial class StatusBar : UserControl
{
private TimeManager _timeManager = null;
public StatusBar()
{
InitializeComponent();
}
private void UserControl_Loaded(object sender, RoutedEventArgs e)
{
DependencyObject parent = this.Parent;
while (parent != null && !(parent is Window))
parent = LogicalTreeHelper.GetParent(parent);
if (parent != null)
{
_timeManager = new TimeManager(parent as Window);
TimePortion.DataContext = _timeManager;
_timeManager.Start();
}
}
private void UserControl_Unloaded(object sender, RoutedEventArgs e)
{
if (_timeManager != null)
{
_timeManager.Dispose();
}
}
}
}
|
|
|
|
|
I´m only a student And I didn´t have better idea and I´m beginner in WPF I have a look at your code. Thank you very much
|
|
|
|
|
No problem. Glad to help.
|
|
|
|
|
I have modified the CellTemplate of a ListView with a custom control called EditBox which allows the user to edit the data in the ListView. The EditBox-class actually has a BeginEdit() function which I want to call, but how can I access the EditBox-instance?
|
|
|
|
|
I covered this in this blog[^] example. You may find it useful.
|
|
|
|
|
Hi
I've wanted to create a simple 3D App in WPF, so i wanna to know we can import 3DMax's models ( *.max files) in Expression Blend ?
If so , how can we do it ?
Many thanks in advance
|
|
|
|
|
I believe the .Max format is protected so it won't be possible to use .max files directly. Instead you might use .3DS. You may even consider importing the 3DS into Blend which can export to Xaml.
I don't know it there are Xaml exporters at the moment. But it should be too hard to write a simple exporter using MaxScript.
Dawn is nature's way of telling you to go to bed.
|
|
|
|
|
You can export 3DS files out to XAML using this[^]. I've not tried it, because I prefer working in Maya and Cinema4D, but it should do the job; and do let us know if it does won't you?
|
|
|
|
|
Thanks Pete.
It's worked.
|
|
|
|
|
Excellent news. That's one for the toolkit then.
|
|
|
|
|
|
I have 2 silverlight controls in a aspx page. Control A fires a static event, and Control B listens to it. Since they are in different DLLs, i've added a reference from Control A into B.
Sadly, B never hears the event, i know its being fired as i've added some debug messages.
Does silverlight not allow this type of functionality ? or am i going about it the wrong way?
Regards,
Gareth.
(FKA gareth111)
|
|
|
|