iSeller Commerce
iSeller POS Retail
iSeller POS F&B
iSeller POS Express
Crosslight
WebUI
ClientUI
What's New
Download Trial
Web Solution
Mobile Solution
Enterprise Solution
Custom Development
Blog
Community
Latest Development Blogs
ForumPostTopic
Browse By Tag
It is possible with the UXStackItem to specify an IconTemplate instead of forcing the use of an actual Icon image. Is there a way to accomplish this with the UXDesktopDockButton? I need to give my developers the ability to use a xaml icon and not force them to use an image. If this can be done, please specify how.
Thanks.
I'm not talking about the UXStackItem, I'm talking about using the UXDesktopDockButton or just the UXDockButton. They don't have a Header property.
When using the UXStackItem, I can just specify an IconTemple instead of an Icon. This is not possible in the UXDockButton.
Actually, UXDesktopDockButton has a content property and which you could use to hold the IconTemplate. Here is a simple snippet of UXDesktopDockButton containing a TextBlock element:
<Intersoft:UXDesktopDockButton> <TextBlock Text="Hello World!"/></Intersoft:UXDesktopDockButton>
In the attached sample, such scenario will be incompatible with the default ImageLoader in the UXDesktopDockButton so you will need to disable the ImageLoader in the DesktopDock.
<Intersoft:UXDesktopDock UseImageLoader="False">
Still no takers on this problem?
I believe you could use the Header property to set a custom content, in this snippet I use a Rectangle element:
<Intersoft:UXStackItem Text="Automator" FontSize="12" Margin="0" Height="64" VerticalAlignment="Top"> <Intersoft:UXStackItem.Header> <Rectangle Fill="Blue" Height="100" Stroke="Black" Width="100"/> </Intersoft:UXStackItem.Header></Intersoft:UXStackItem>
Okay, here is what I've been trying to do and I think I may have uncovered a bug in the UXDesktopDockButton control:
I have a datasource with a propery of type UIElement that I'm trying to bind to the Icon property of the UXDesktopDockButton. I created a converter that will convert the UIElement to a WriteableBitmap at the time of binding. Now I can get the converter to work just fine on an Image control's Source property, but on the UXDesktopDockButton's Icon property I get a blank button. See the sample code below or the attached project to recreate the issue:
Note: Ignore the bit about the DataTemplate in the converter, that code is not used yet.
Coverter Code:
using System;using System.Windows;using System.Windows.Controls;using System.Windows.Data;using System.Windows.Media;using System.Windows.Media.Imaging; namespace SilverlightPlayground{ public class DependencyObjectToImageSourceConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { int height = 16; int width = 16; if (parameter != null) { if (parameter is string) { string rawParameter = parameter as string; string[] paramArray = rawParameter.Split(','); if (paramArray != null && paramArray.Length > 0) { int.TryParse(paramArray[0], out width); int.TryParse(paramArray[1], out height); } } } if (value is UIElement) { UIElement element = (UIElement)value; if (element is FrameworkElement) { ((FrameworkElement)element).Width = width; ((FrameworkElement)element).Height = height; } WriteableBitmap bitmap = new WriteableBitmap(width, height); bitmap.Render(element, null); bitmap.Invalidate(); return bitmap; } else if (value is DataTemplate) { UIElement element = ((DataTemplate)value).LoadContent() as UIElement; if (element is FrameworkElement) { ((FrameworkElement)element).Width = width; ((FrameworkElement)element).Height = height; } StackPanel grid = new StackPanel(); grid.Background = new SolidColorBrush(Colors.Green); grid.Width = grid.Height = 300; grid.Children.Add(element); ((Grid)((UserControl)Application.Current.RootVisual).Content).Children.Add(grid); grid.UpdateLayout(); WriteableBitmap bitmap = new WriteableBitmap(width, height); bitmap.Render(grid, null); bitmap.Invalidate(); //grid.Children.Remove(element); Image img = new Image(); img.Source = bitmap; grid.Children.Add(img); grid.UpdateLayout(); return bitmap; } return value; } public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { throw new NotImplementedException(); } }}
MainPage.xaml:
<UserControl xmlns:Intersoft="http://intersoft.clientui.com/schemas" x:Class="SilverlightPlayground.MainPage" 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:converters="clr-namespace:SilverlightPlayground" mc:Ignorable="d" d:DesignHeight="300" d:DesignWidth="400"> <UserControl.Resources> <converters:DependencyObjectToImageSourceConverter x:Key="DependencyObjectToImageSourceConverter"/> </UserControl.Resources> <Grid x:Name="LayoutRoot" Background="White"> <Image x:Name="BoundImage" Source="{Binding SomeUIElementProperty, Converter={StaticResource DependencyObjectToImageSourceConverter}, ConverterParameter='200,50'}"/> <Intersoft:UXDesktopDock> <Intersoft:UXDesktopDockButton Text="Test Button" Icon="{Binding SomeUIElementProperty, Converter={StaticResource DependencyObjectToImageSourceConverter}, ConverterParameter='50,50'}" /> </Intersoft:UXDesktopDock> </Grid></UserControl>
MainPage.xaml.cs:
using System.Windows;using System.Windows.Controls; namespace SilverlightPlayground{ public partial class MainPage : UserControl { public MainPage() { InitializeComponent(); this.DataContext = this; } public UIElement SomeUIElementProperty { get { Grid grid = new Grid(); TextBlock text = new TextBlock(); text.FontSize = 12; text.Text = "Hello World!"; grid.Children.Add(text); return grid; } } }}
Turning off the image loader did the trick! Thanks!
I couldn't get the Content property to work, though.
or
Choose this if you're already a member of Intersoft Community Forum. You can link your OpenID account to your existing Intersoft Social ID.
Choose this if you don't have an Intersoft account yet. Your authenticated OpenID will be automatically linked to your new Intersoft account.
Enter your Wordpress Blogname