8,756
社区成员




<Intersoft:UXWindow
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"
mc:Ignorable="d"
xmlns:Intersoft="http://intersoft.clientui.com/schemas"
x:Class="InfoWorld.InfoWindow"
Header="InfoWindow"
d:DesignWidth="640" d:DesignHeight="480" Background="Transparent" ResizeGripVisibility="Visible"
x:Name="wndx"
>
<Intersoft:UXWindow.CommandBarTemplate>
<DataTemplate x:Name="tmp">
<Button Height="25" Content="这里如何将内容绑定到wndx(类型是UXWindow)的ProgressBarValue上去?"></Button>
</DataTemplate>
</Intersoft:UXWindow.CommandBarTemplate>
<!--<Intersoft:UXWindow.HeaderTemplate>
<DataTemplate>
<Button>hello,world</Button>
</DataTemplate>
</Intersoft:UXWindow.HeaderTemplate>
<Intersoft:UXWindow.SecondaryToolBarTemplate>
<DataTemplate>
<Button>toolbar2</Button>
</DataTemplate>
</Intersoft:UXWindow.SecondaryToolBarTemplate>-->
<Grid x:Name="LayoutRoot" />
</Intersoft:UXWindow>
public partial class InfoWindow : UXWindow{
public static DependencyProperty ProgressBarValueProperty = DependencyProperty.Register("ProgressBarValue", typeof(int), typeof(InfoWindow), null);
public int ProgressBarValue
{
get
{
return (int)GetValue(ProgressBarValueProperty);
}
set
{
SetValue(ProgressBarValueProperty, value);
}
}
}
{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type UXWindow}}, Path=ProgressBarValue}
<Grid>
<TextBlock Name="tst" Text="Test"></TextBlock>
<Button>
<ContentControl>
<TextBlock Text="{Binding ElementName=tst,Path=Text}"></TextBlock>
</ContentControl>
</Button>
</Grid>
Button btn = (Button)VisualTreeHelper.GetChild(this.tmp.LoadContent(), 0);
InfoWindow window = ...
window.ProgressBarValue = 29;//结果,就把DataTemplate中的按钮的Content值设置成了29.
UXWindow parent = FindParent<UXWindow>(this);
parent.ProgressBarValue = button.Content;